Пример #1
0
        bool CreateConnection(Socket connection)
        {
            var conn = new ReceiverConnection(connection, new[] { PublicConnectionPassword });

            bool accepted = false;
            try
            {
                accepted = conn.DoInitialHandshake();
            }
            catch (InvalidHandshakeException ex)
            {
                RaiseFailedConnectionAttempt(ex);
            }

            if (accepted)
                RaiseGotConnection(conn);
            else
                conn.Dispose();

            return accepted;
        }
Пример #2
0
 void RaiseGotConnection(ReceiverConnection conn)
 {
     UIThreadSyncContext.Send(new SendOrPostCallback(state =>
     {
         if (GotConnection != null)
             GotConnection(conn);
     }), null);
 }