예제 #1
0
        public PalBot(IPacketSerializer packetSerializer,
                      IPacketDeserializer packetDeserializer,
                      IPacketMapper packetMapper,
                      IPacketWatcher packetWatcher,
                      IPacketTemplates packetTemplates,
                      IZLibCompression compression,
                      IAuthenticationUtility authentication,
                      IPacketHandlerHub handlerHub,
                      ISubProfiling subProfiling,
                      IPluginManager pluginManager,
                      IRoleManager roleManager,
                      IBroadcastUtility broadcast)
        {
            this.packetSerializer   = packetSerializer;
            this.packetDeserializer = packetDeserializer;
            this.packetMapper       = packetMapper;
            this.packetWatcher      = packetWatcher;
            this.packetTemplates    = packetTemplates;
            this.compression        = compression;
            this.authentication     = authentication;
            this.handlerHub         = handlerHub;
            this.SubProfiling       = subProfiling;
            this.pluginManager      = pluginManager;
            this.RoleManager        = roleManager;
            this.On        = broadcast;
            this.broadcast = (BroadcastUtility)broadcast;

            _client = new NetworkClient(DefaultHost, DefaultPort);
            _client.OnDisconnected += (c) => _disconnected?.Invoke();
            _client.OnDisconnected += (c) => ((BroadcastUtility)On).BroadcastDisconnected();
            _client.OnException    += (e, n) => _error?.Invoke(e, n);
            _client.OnException    += (e, n) => ((BroadcastUtility)On).BroadcastException(e, n);
            _client.OnDataReceived += (c, b) => this.packetDeserializer.ReadPacket(c, b);

            On.Exception += (e, n) => _error?.Invoke(e, n);
            On.Message   += (b, m) => _message?.Invoke(b, m);
            this.broadcast.PacketParsed += (c, p) => PacketReceived(p);
        }
예제 #2
0
 protected AbstractReciver(IReciveTransmissionProtocol transmissionProtocol, IPacketDeserializer <T> deserializer)
 {
     _transmissionProtocol = transmissionProtocol;
     _deserializer         = deserializer;
 }
예제 #3
0
 public MockReciver(IReciveTransmissionProtocol transmissionProtocol, IPacketDeserializer <int> deserializer)
     : base(transmissionProtocol, deserializer)
 {
 }
예제 #4
0
 public void Setup()
 {
     _protocol = Substitute.For <IReciveTransmissionProtocol>();
     _parser   = Substitute.For <IPacketDeserializer <int> >();
     _reciver  = new MockReciver(_protocol, _parser);
 }
예제 #5
0
 public RecordedInputReciver(IReciveTransmissionProtocol transmissionProtocol, IPacketDeserializer <RecordedInput> deserializer) : base(transmissionProtocol, deserializer)
 {
 }
 public TestMessagePacketDeserializer()
 {
     _customTypeDtoDeserializer    = new CustomTypeDtoPacketDeserializer();
     _stringsObjectDtoDeserializer = new StringsObjectDtoPacketDeserializer();
 }
예제 #7
0
 protected ClientHandlerDeserializer(MhfServer server, IPacketDeserializer <T> deserializer) : base(server)
 {
     _deserializer = deserializer;
 }