void StartClient() { networkClient = new NetworkingSockets(); Address address = new Address(); address.SetAddress("::1", 7777); connection = networkClient.Connect(address); status = OnClientStatusUpdate; }
void Awake() { utils.SetDebugCallback(DebugType.Everything, debug); client = new NetworkingSockets(); address = new Address(); address.SetAddress("::1", clientPort); //ipv6 localhost connection = client.Connect(address); InitCallbacks(); StartCoroutine(HandleClient()); }
void Start() { Library.Initialize(); ushort port = 8080; this.client = new NetworkingSockets(); Address address = new Address(); address.SetAddress("::1", port); this.connection = client.Connect(ref address); this.status = (info, context) => { switch (info.connectionInfo.state) { case ConnectionState.None: break; case ConnectionState.Connected: Debug.Log("Client connected to server - ID: " + connection); break; case ConnectionState.ClosedByPeer: client.CloseConnection(connection); Debug.Log("Client disconnected from server"); break; case ConnectionState.ProblemDetectedLocally: client.CloseConnection(connection); Debug.Log("Client unable to connect"); break; } }; DebugCallback debug = (type, message) => { Debug.Log("Debug - Type: " + type + ", Message: " + message); }; NetworkingUtils utils = new NetworkingUtils(); utils.SetDebugCallback(DebugType.Everything, debug); }
public void ConnectToServer(string username, OnConnect onConnect, OnDisconnect onDisconnect, OnReject onReject) { this.onConnect = onConnect; this.onDisconnect = onDisconnect; this.onReject = onReject; utils = new NetworkingUtils(); utils.SetDebugCallback(DebugType.Message, debug); Reset(); client = new NetworkingSockets(); Address address = new Address(); address.SetAddress(serverIP, serverport); status = OnClientStatusUpdate; utils.SetStatusCallback(status); connection = client.Connect(ref address); }
public void ConnectToServer(string ip, ushort port, string user) { // Create a debug log file Type skaterSpawner = AccessTools.TypeByName("SkaterSpawner"); if (skaterSpawner != null) { object spawnerInstance = Traverse.Create(skaterSpawner).Property("Instance").GetValue(); if (spawnerInstance != null) { Traverse.Create(spawnerInstance).Method("RemoveModelCoroutine").GetValue(); } } int i = 0; while (this.debugWriter == null) { string filename = "Multiplayer Debug Client" + (i == 0 ? "" : " " + i.ToString()) + ".txt"; try { this.debugWriter = new StreamWriter(filename); } catch (Exception) { this.debugWriter = null; i++; } } this.debugWriter.AutoFlush = true; this.debugWriter.WriteLine("Attempting to connect to server ip {0} on port {1}", ip, port.ToString()); MultiplayerUtils.serverMapDictionary.Clear(); this.playerController = new MultiplayerLocalPlayerController(this.debugWriter); this.playerController.ConstructPlayer(); this.playerController.username = user; // TODO: Add popup window with a download for vc_redistx64.exe Library.Initialize(); client = new NetworkingSockets(); IPAddress serverIP = null; if (!IPAddress.TryParse(ip, out serverIP)) { try { IPHostEntry hostInfo = Dns.GetHostEntry(ip); foreach (IPAddress address in hostInfo.AddressList) { if (address.MapToIPv4() != null) { serverIP = address.MapToIPv4(); } } } catch (Exception) { } } serverPort = port; serverIPString = serverIP.ToString(); Address remoteAddress = new Address(); remoteAddress.SetAddress(serverIP.ToString(), port); connection = client.Connect(ref remoteAddress); status = StatusCallback; #if !VALVESOCKETS_SPAN netMessages = new NetworkingMessage[maxMessages]; #endif networkMessageThread = new Thread(UpdateClient); networkMessageThread.IsBackground = true; networkMessageThread.Start(); decompressionThread = new Thread(DecompressSoundAnimationQueue); decompressionThread.IsBackground = true; decompressionThread.Start(); }
public void ConnectToServer(string ip, ushort port, string user) { // Create a debug log file int i = 0; while (this.debugWriter == null) { string filename = "Multiplayer Debug Client" + (i == 0 ? "" : " " + i.ToString()) + ".txt"; try { this.debugWriter = new StreamWriter(filename); } catch (Exception) { this.debugWriter = null; i++; } } this.debugWriter.AutoFlush = true; this.debugWriter.WriteLine("Attempting to connect to server ip {0} on port {1}", ip, port.ToString()); MultiplayerUtils.serverMapDictionary.Clear(); this.playerController = new MultiplayerLocalPlayerController(this.debugWriter); this.playerController.ConstructPlayer(); this.playerController.username = user; Library.Initialize(); client = new NetworkingSockets(); IPAddress serverIP = null; if (!IPAddress.TryParse(ip, out serverIP)) { try { IPHostEntry hostInfo = Dns.GetHostEntry(ip); foreach (IPAddress address in hostInfo.AddressList) { if (address.MapToIPv4() != null) { serverIP = address.MapToIPv4(); } } } catch (Exception) { } } Address remoteAddress = new Address(); remoteAddress.SetAddress(serverIP.ToString(), port); connection = client.Connect(ref remoteAddress); status = StatusCallback; #if !VALVESOCKETS_SPAN netMessages = new NetworkingMessage[maxMessages]; #endif networkMessageThread = new Thread(UpdateClient); networkMessageThread.IsBackground = true; networkMessageThread.Start(); }