Example #1
0
        private async void HandleInitialHandshakeComplete(NetPeerData peer,
                                                          NetConnection sender,
                                                          NetUserId userId,
                                                          string userName,
                                                          NetEncryption?encryption,
                                                          LoginType loginType)
        {
            var channel = new NetChannel(this, sender, userId, userName, loginType);

            _assignedUserIds.Add(userId, sender);
            _assignedUsernames.Add(userName, sender);
            _channels.Add(sender, channel);
            peer.AddChannel(channel);
            channel.Encryption = encryption;

            _strings.SendFullTable(channel);

            try
            {
                await Task.Delay(1000);

                await _serializer.Handshake(channel);
            }
            catch (TaskCanceledException)
            {
                // Client disconnected during handshake.
                return;
            }

            Logger.InfoS("net", "{ConnectionEndpoint}: Connected", channel.RemoteEndPoint);

            OnConnected(channel);
        }
Example #2
0
        private async void HandleInitialHandshakeComplete(NetPeerData peer, NetConnection sender)
        {
            var session = _assignedSessions[sender];

            var channel = new NetChannel(this, sender, session);

            _channels.Add(sender, channel);
            peer.AddChannel(channel);

            _strings.SendFullTable(channel);

            try
            {
                await _serializer.Handshake(channel);
            }
            catch (TaskCanceledException)
            {
                // Client disconnected during handshake.
                return;
            }

            Logger.InfoS("net", "{ConnectionEndpoint}: Connected", channel.RemoteEndPoint);

            OnConnected(channel);
        }