Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Added server code (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
munawarb committed Apr 29, 2017
1 parent 3397bd1 commit 2b232e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
25 changes: 2 additions & 23 deletions TDV/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ public static string serverTag
set { m_serverTag = value; }
}

public static bool connect(String host, String password, int port, String tag)
public static bool connect(String host, String callSign, int port)
{
System.Diagnostics.Trace.WriteLine("Server tag is " + tag);
ports = new int[]{4444, 4445, 4567, 6969, 32000 };
if (dataLocker == null)
dataLocker = new object();
Expand All @@ -206,7 +205,6 @@ public static bool connect(String host, String password, int port, String tag)
isConnected = false; error = false;
live = false;
client = new TcpClient();
serverTag = tag;
int i = (port != 0) ? Array.IndexOf(ports, port) : 0;
int time = 0;

Expand Down Expand Up @@ -237,22 +235,8 @@ public static bool connect(String host, String password, int port, String tag)
{
using (BinaryWriter writer = new BinaryWriter(new MemoryStream()))
{
writer.Write((int)0);
System.Diagnostics.Trace.WriteLine("After int: " + writer.BaseStream.Length);
writer.Write(Convert.ToSingle(Common.applicationVersion));
writer.Write(tag);
System.Diagnostics.Trace.WriteLine("Tag is now " + tag);
if (password != null)
writer.Write(password);
writer.Write(callSign);
writer.Flush();
System.Diagnostics.Trace.WriteLine("After password: " + writer.BaseStream.Length);
writer.BaseStream.Position = 0;
writer.Write((int)(writer.BaseStream.Length - 4));
writer.Flush();

System.Diagnostics.Trace.WriteLine("After data size print " + writer.BaseStream.Length);
System.Diagnostics.Trace.WriteLine("SSL packet size: " + (writer.BaseStream.Length - 4));
writer.BaseStream.Position = 0;
CSCommon.sendData(client, writer);
} //using
LoginMessages resp = LoginMessages.none;
Expand Down Expand Up @@ -300,11 +284,6 @@ public static bool connect(String host, String password, int port, String tag)
return true;
}

public static bool connect(String host, String tag, String password)
{
return connect(host, password, 4444, tag);
}

private static void connectedEvent(IAsyncResult result)
{
try
Expand Down
6 changes: 5 additions & 1 deletion TDV/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,12 @@ public static void startGame()
* Once all adds are complete, client will receive a startGame command from the server.
* */
bool connected = false;
SapiSpeech.speak("Enter IP address or domain to connect to.", SapiSpeech.SpeakFlag.interruptable);
String ip = Common.mainGUI.receiveInput();
SapiSpeech.speak("Enter your call sign. This is how you'll be known on the server.", SapiSpeech.SpeakFlag.interruptable);
String callSign = Common.mainGUI.receiveInput();
DSound.playAndWait(DSound.NSoundPath + "\\c1.wav");
connected = Client.connect("127.0.0.1", null, 4444, getLicensedID());
connected = Client.connect(ip, callSign, 4444);
failedConnect = !connected;
if (!connected)
{
Expand Down
Binary file modified TDV/Three-D Velocity.v12.suo
Binary file not shown.

0 comments on commit 2b232e6

Please sign in to comment.