Exemplo n.º 1
0
        public ServerFrame(NetPeerConfiguration config,
                           IMessageReceiver receiver,
                           MessageSender sender,
                           PersistentNetworkConnector connector,
                           IAuthenticator authenticator)
        {
            _server = new NetServer(config);

            Receiver      = receiver;
            Sender        = sender;
            Connector     = connector;
            Authenticator = authenticator;

            Sender.Sent      += Sender_Send;
            Sender.Broadcast += Sender_Broadcast;
        }
Exemplo n.º 2
0
        public static ServerFrame Create(string id, int timeout, int ping, int port, IMessageReceiver receiver, IAuthenticator authenticator, PersistentNetworkConnector connector)
        {
            NetPeerConfiguration config = new NetPeerConfiguration(id)
            {
                PingInterval      = ping,
                ConnectionTimeout = timeout,
                Port = port,
                UseMessageRecycling      = true,
                SendBufferSize           = 134_216_704,
                ReceiveBufferSize        = 134_216_704,
                MaximumConnections       = 100,
                MaximumHandshakeAttempts = 100
            };

            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);

#if DEBUG
            config.SimulatedMinimumLatency   = 0.015f;
            config.SimulatedRandomLatency    = 0.010f;
            config.SimulatedDuplicatesChance = 0.01f;
            config.SimulatedLoss             = 0.01f;
#endif // DEBUG

            var sender = MessageSenderFactory.CreateMessageSender();

            ServerFrame sf = new ServerFrame(config, receiver, sender, connector, authenticator);
            return(sf);
        }
    }