/// <summary>
        /// Подключается к серверу
        /// </summary>
        public static AsynchronousClient Connect(IPEndPoint remoteEndPoint)
        {
            try
            {
                var newClient = new AsynchronousClient(remoteEndPoint);

                var connectionObject = new ClientConnectionObject(newClient, remoteEndPoint);
                newClient.Socket.BeginConnect(remoteEndPoint, ConnectCallback, connectionObject);
                newClient._connectDone.WaitOne();

                return(newClient);
            }
            catch (Exception e)
            {
                Debug.Log(e);
            }
            return(null);
        }
Ejemplo n.º 2
0
 public ClientStateObject(AsynchronousClient client)
 {
     Client         = client;
     _messageLength = 0;
     Buffer         = new byte[client.IsClientSide ? Params.CLIENT_BUFFER_SIZE : Params.SERVER_BUFFER_SIZE];
 }
Ejemplo n.º 3
0
 public ClientConnectionObject(AsynchronousClient client, IPEndPoint remoteEndPoint)
 {
     Client         = client;
     RemoteEndPoint = remoteEndPoint;
 }