Beispiel #1
0
 public void Broadcast(DiepConnection Connection, Diep.GameConnection.Messages.Message message)
 {
     foreach (var connection in Connections.ToArray().Where(a => Connection == null || a.Id != Connection.Id))
     {
         connection.Enqueue(message);
     }
 }
Beispiel #2
0
        private void FreshConnection_MessageReceived(DiepConnection Connection, Diep.GameConnection.Messages.Message Message)
        {
            if (Connection is ServerDiepConnection sdc)
            {
                switch (Message.Type)
                {
                case MessageType.Message:
                    break;

                case MessageType.ConnectMessage:
                    AuthenticateClient(sdc, Message as ConnectMessage);
                    SpawnTank(sdc);
                    SendOtherTanks(Connection);
                    break;

                case MessageType.TankMoveMessage:
                    Broadcast(Connection, Message);
                    break;

                case MessageType.TankSpawnMessage:
                    Broadcast(null, Message);
                    break;

                case MessageType.ShootMessage:
                    ExecuteShoot(Connection as ServerDiepConnection, Message as ShootMessage);
                    break;

                default:
                    break;
                }
            }
        }