Esempio n. 1
0
        private void OnAccept(IAsyncResult result)
        {
            try
            {
                var socket     = serverSocket.EndAccept(result);
                var connection = new TCPConnection(socket);
                if (OnConnection != null)
                {
                    OnConnection(connection);
                }
            }
            catch (ObjectDisposedException)
            {
                // listening socket has been closed cleanly
                return;
            }

            serverSocket.BeginAccept(OnAccept, null);
        }
Esempio n. 2
0
File: Types.cs Progetto: UCL-VR/ubiq
        public static INetworkConnection Resolve(ConnectionDefinition definition)
        {
            INetworkConnection connection;

            switch (definition.type)
            {
            case ConnectionType.tcp_client:
            case ConnectionType.tcp_server:
                connection = new TCPConnection(definition);
                break;

            case ConnectionType.udp:
                connection = new UDPConnection(definition);
                break;

            case ConnectionType.websocket:
                connection = new WebSocketConnection(definition);
                break;

            default:
                throw new NotImplementedException();
            }
            return(connection);
        }