示例#1
0
        public NetworkConnection(string server, int port)
        {
            _tcpConnectionReady = false;

            serverName             = server;
            hostPort               = port;
            maxNumberOfConnections = 1;
            methodToSendRequest    = delegate()
            {
                Debug.LogError("SendRequest() : delegate not implemented");
            };
            methodToComputeData = delegate(NetworkData input)
            {
                Debug.LogError("ComputeNetworkData() : delegate not implemented");
                return(false);
            };
            methodToAbandonConnection = delegate()
            {
                Debug.LogError("CloseConnection() : delegate not implemented");
            };
        }
示例#2
0
    private NetworkConnection createNetworkConnectionWithDelegates(SendRequest methodToSendRequestOnceConnectionIsEstablished, ComputeNetworkData methodToComputeDataOnceTheyAreReceived)
    {
        NetworkConnection connection = new NetworkConnection(serverName, hostPort);

        connection.methodToSendRequest       = methodToSendRequestOnceConnectionIsEstablished;
        connection.methodToComputeData       = methodToComputeDataOnceTheyAreReceived;
        connection.methodToAbandonConnection = AbandonConnection;
        if (!readLinesThread.IsAlive)
        {
            readLinesThread = new Thread(() => ReadLinesInfinite());
            readLinesThread.Start();
            Debug.Log("Start new readLine thread");
        }
        return(connection);
    }