private void Start() { mSocketDebug = GetComponent <SocketDebug>(); if (Host(kPort)) { mSocketDebug.DebugLog("lServer: started"); } }
public void Update() { if (OnClientConnectResult != null) { mSocketDebug.DebugLog("lServer: Handling client connecting"); try { Socket client = mSocket.EndAccept(OnClientConnectResult); mSocketDebug.DebugLog("lServer: Client connected"); mClients.Add(client); SocketRead.Begin(client, OnReceive, OnReceiveError); OnClientConnectResult = null; } catch (System.Exception e) { mSocketDebug.DebugLogError("lServer: Exception when accepting incoming connection: " + e); } try { mSocket.BeginAccept(new System.AsyncCallback(OnClientConnect), mSocket); } catch (System.Exception e) { mSocketDebug.DebugLogError("lServer: Exception when starting new accept process: " + e); } } if (mBatchedContent.Count > 0) { foreach (JSONData transaction in mBatchedContent) { Debug.Log(transaction.ToString()); } while (mBatchedContent.Count > 0) { mBatchedContent.Remove(0); } } }
public void Update() { if (!mSocket.Connected) { mSocketDebug.DebugLog("lClient: Connecting..."); try { mSocket.Connect(new IPEndPoint(IP, kPort)); } catch (System.Exception e) { mSocketDebug.DebugLogError("lClient: Exception: " + e.Message); mSocketDebug.DebugLogError("lClient: Failed to connect to " + ip + " on port " + kPort); } if (mSocket.Connected) { mSocketDebug.DebugLog("lClient: Successfully connected to " + ip + " on port " + kPort); mSocketDebug.DebugLog("lClient: started"); SocketRead.Begin(mSocket, OnReceive, OnError); } } }
private void Start() { mSocketDebug = GetComponent<SocketDebug>(); if (Host(kPort)) { mSocketDebug.DebugLog("lServer: started"); } }