Ejemplo n.º 1
0
        /// <summary>
        /// Handles a connect packet
        /// </summary>
        /// <param name="connect">Connect.</param>
        private void HandleConnect(UdpConnect connect, EndPoint endpoint)
        {
            var ipEndpoint = (IPEndPoint)endpoint;

            //var address = ipEndpoint.Address;

            if (availablePorts.Count == 0) // no available ports
            {
                Send(new UdpDisconnect(connect.clientSalt, UdpDisconnectReason.ServerFull), endpoint);
                return;
            }

            if (connections.TryGetValue(ipEndpoint, out var connection))
            {
                Send(new UdpDisconnect(connect.clientSalt, UdpDisconnectReason.ExistingConnection), endpoint);
                return;
            }

            var state = CreateConnectionRequest(connect.clientSalt, ipEndpoint);

            requestStates[ipEndpoint] = state;

            var saltSolution = Udp.CreateSalt(state.clientSalt, state.serverSalt);

            Send(new UdpChallenge(state.clientSalt, state.serverSalt), endpoint);
        }
Ejemplo n.º 2
0
 public UdpIntegration(UdpConnect connector)
 {
     this.connector = connector;
 }