Ejemplo n.º 1
0
 private void SendResponse(InternalMessage message)
 {
     if (clients.TryGetValue(message.Sender, out Client client))
     {
         client.SendMessage(message);
     }
 }
Ejemplo n.º 2
0
        private void ProcessMessage(InternalMessage message)
        {
            switch (message.MessageType)
            {
            case InternalMessageType.RegistrationRequest:
                break;

            case InternalMessageType.ConnectionRequest:
                EstablishConnection(message.Sender, message.Content);
                SendResponse(message);
                break;

            case InternalMessageType.BroacastRequest:
                if (clients.TryGetValue(message.Sender, out Client client))
                {
                    short requiredBroadcastedType = short.Parse(message.Content);
                    switch (requiredBroadcastedType)
                    {
                    case (short)BroadcastSettingCodes.Cancel:
                        client.Operations.CancelBroadcasting();
                        break;

                    case (short)BroadcastSettingCodes.BroadcastEverythingTrue:
                        client.Operations.BroadcastEverything = true;
                        break;

                    case (short)BroadcastSettingCodes.BroadcastEverythingFalse:
                        client.Operations.BroadcastEverything = false;
                        break;

                    default:
                        client.Operations.SetBroadcastedType(requiredBroadcastedType);
                        break;
                    }
                    client.SendMessage(message);
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
 public void SendMessage(InternalMessage message) => stream.Write(message);