Ejemplo n.º 1
0
 private async void SendMessage(GuideClientMessageType messageType, Action <BinaryWriter> writeData = null)
 {
     if (!_stream.CanWrite)
     {
         return;
     }
     var message = new MessageWrapper(ClientType.Guide, (int)messageType, GuideId);
     var buffer  = message.WriteBuffer(writeData);
     await _stream.WriteAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
 }
Ejemplo n.º 2
0
 public void AddHandler <T>(GuideClientMessageType messageType, Func <BinaryReader, T> messageReader, Action <IGuideClient, MessageWrapper, T> messageHandler) where T : class
 {
     _messageReaders.Add((int)messageType, messageReader);
     _guideHandlers.Add((int)messageType, (service, message) => messageHandler(service, message, message.GetData <T>()));
 }