예제 #1
0
 private void Start()
 {
     mSocketDebug = GetComponent <SocketDebug>();
     if (Host(kPort))
     {
         mSocketDebug.DebugLog("lServer: started");
     }
 }
예제 #2
0
    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);
            }
        }
    }
예제 #3
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);
            }
        }
    }
예제 #4
0
 private void Start()
 {
     mSocketDebug = GetComponent<SocketDebug>();
     if (Host(kPort))
     {
         mSocketDebug.DebugLog("lServer: started");
     }
 }