Пример #1
0
        public NetworkBase(NetworkLogger logger)
        {
            this.Listener   = new EventBasedNetListener();
            this.NetManager = new NetManager(this.Listener)
            {
                NatPunchEnabled   = true,
                DisconnectTimeout = (int)TimeSpan.FromSeconds(60).TotalMilliseconds,
            };

            this.processor = new NetPacketProcessor();

            // TODO: somehow register all types via dependency injection?

            this.processor.RegisterNestedType(Vector3Serializer.Write, Vector3Serializer.Read);
            this.processor.SubscribeReusable <NetCommand, NetPeer>(this.OnCommandReceived);

            this.Writer = new NetDataWriter();
            this.Logger = logger;

            this.RegisterHandlers();

            this.Listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) =>
            {
                this.processor.ReadAllPackets(dataReader, fromPeer);
            };
        }
Пример #2
0
 public Client(NetworkLogger logger)
     : base(logger)
 {
 }
Пример #3
0
 public Server(NetworkLogger logger)
     : base(logger)
 {
 }