Beispiel #1
0
        /// <summary>
        /// Triggered by <see cref="Connection.ConnectedSocket"/>.
        /// Adds the <see cref="Connection"/> to <see cref="allConnections"/> and
        /// makes a call to <see cref="connectedSocketCall"/>.
        /// </summary>
        /// <param name="sender"><see cref="Connection"/></param>
        /// <param name="e">A <see cref="SocketClient.ConnectedEventArgs"/> object</param>
        private void ConnectedSocket(object sender, EventArgs e)
        {
            SocketClient.ConnectedEventArgs cea =
                (SocketClient.ConnectedEventArgs)e;

            // set up the new connection to listen for message
            Connection newConnection = new Connection();

            newConnection.Connect(cea.newSocket);
            newConnection.DisconnectedEvent    += new EventHandler(DeferredDisconnectedSocket);
            newConnection.MessageRecievedEvent += new EventHandler(MessageReceived);
            allConnections.AddLast(newConnection);

            // pass along the event
            if (ConnectedSocketCall != null)
            {
                ConnectedSocketCall(this);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Triggered by <see cref="SocketClient.ConnectedEvent"/> event.
        /// Starts listening for messages on the received socket and
        /// calls <see cref="ConnectedEvent"/>.
        /// </summary>
        /// <param name="sender"><see cref="SocketClient"/></param>
        /// <param name="args">A <see cref="SocketClient.ConnectedEventArgs"/> object.</param>
        private void ConnectedSocket(object sender, EventArgs args)
        {
            System.Diagnostics.Debugger.Log(1, "", "connected\n");
            SocketClient.ConnectedEventArgs cea =
                args as SocketClient.ConnectedEventArgs;

            // connect to the incoming connection
            if (CurrentSocketClient == null)
            {
                CurrentSocketClient = new SocketClient();
            }
            CurrentSocketClient.Connect(cea.newSocket);

            // start listening for new connections
            StartListening();

            // fire connected event!
            if (ConnectedEvent != null)
            {
                ConnectedEvent(sender, cea);
            }
        }