Example #1
0
        /// <summary>
        /// Sends a request to server, retrieves all profile values, and applies them to a provided profile
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="callback"></param>
        /// <param name="connection"></param>
        public void GetProfileValues(ObservableProfile profile, SuccessCallback callback, IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(false, "Not connected");
                return;
            }

            connection.SendMessage((short)MstMessageCodes.ClientProfileRequest, profile.PropertyCount, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(false, response.AsString("Unknown error"));
                    return;
                }

                // Use the bytes received, to replicate the profile
                profile.FromBytes(response.AsBytes());

                // Listen to profile updates, and apply them
                connection.SetHandler((short)MstMessageCodes.UpdateClientProfile, message =>
                {
                    //UnityEngine.Debug.LogError($"Profile Updated from server");

                    profile.ApplyUpdates(message.AsBytes());
                });

                callback.Invoke(true, null);
            });
        }
Example #2
0
        public SpawnerController(int spawnerId, IClientSocket connection, SpawnerOptions options)
        {
            Connection = connection;
            SpawnerId  = spawnerId;
            Options    = options;

            DefaultSpawnerSettings = new DefaultSpawnerConfig()
            {
                MasterIp   = connection.ConnectionIp,
                MasterPort = connection.ConnectionPort,
                MachineIp  = options.MachineIp
            };

            // Add handlers
            connection.SetHandler((short)MsfOpCodes.SpawnRequest, HandleSpawnRequest);
            connection.SetHandler((short)MsfOpCodes.KillSpawnedProcess, HandleKillSpawnedProcessRequest);
        }
        public SpawnRequestController(int spawnId, IClientSocket connection)
        {
            _connection = connection;
            SpawnId     = spawnId;

            // Set handlers
            connection.SetHandler((short)MsfOpCodes.SpawnRequestStatusChange, HandleStatusUpdate);
        }
Example #4
0
        /// <summary>
        /// Create new <see cref="SpawnRequestController"/> instance
        /// </summary>
        /// <param name="spawnId"></param>
        /// <param name="connection"></param>
        /// <param name="spawnOptions"></param>
        public SpawnRequestController(int spawnId, IClientSocket connection, MstProperties spawnOptions)
        {
            this.connection = connection;
            SpawnTaskId     = spawnId;
            SpawnOptions    = spawnOptions;

            // Set handlers
            connection.SetHandler((short)MstMessageCodes.SpawnRequestStatusChange, StatusUpdateHandler);
        }
        /// <summary>
        /// Create new <see cref="SpawnRequestController"/> instance
        /// </summary>
        /// <param name="spawnId"></param>
        /// <param name="connection"></param>
        /// <param name="spawnOptions"></param>
        public SpawnRequestController(int spawnId, IClientSocket connection, Dictionary <string, string> spawnOptions)
        {
            this.connection = connection;
            SpawnId         = spawnId;
            SpawnOptions    = spawnOptions;

            // Set handlers
            connection.SetHandler((short)MsfMessageCodes.SpawnRequestStatusChange, StatusUpdateHandler);
        }
Example #6
0
        public RoomController(int roomId, IClientSocket connection, RoomOptions options)
        {
            Connection = connection;
            RoomId     = roomId;
            Options    = options;

            // Add handlers
            connection.SetHandler((short)MsfOpCodes.ProvideRoomAccessCheck, HandleProvideRoomAccessCheck);
        }
Example #7
0
        public SpawnerController(int spawnerId, IClientSocket connection, SpawnerOptions options)
        {
            Connection = connection;
            SpawnerId  = spawnerId;
            Options    = options;

            DefaultSpawnerSettings = new DefaultSpawnerConfig()
            {
                MasterIp         = connection.ConnectionIp,
                MasterPort       = connection.ConnectionPort,
                MachineIp        = options.MachineIp,
                SpawnInBatchmode = Msf.Args.IsProvided("-batchmode")
            };

            // Add handlers
            connection.SetHandler((short)MsfMessageCodes.SpawnProcessRequest, SpawnProcessRequestHandler);
            connection.SetHandler((short)MsfMessageCodes.KillProcessRequest, KillProcessRequestHandler);
        }
        public SpawnRequestController(string spawnId, IClientSocket connection, string spawnCode)
        {
            _connection    = connection;
            SpawnId        = spawnId;
            this.spawnCode = spawnCode;

            // Set handlers
            connection.SetHandler((short)MsfOpCodes.SpawnRequestStatusChange, HandleStatusUpdate);
        }
Example #9
0
        /// <summary>
        /// Create new instance of spawner controller
        /// </summary>
        /// <param name="spawnerId"></param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        public SpawnerController(int spawnerId, IClientSocket connection, SpawnerOptions spawnerOptions)
        {
            Logger = Mst.Create.Logger(typeof(SpawnerController).Name, LogLevel.Info);

            Connection = connection;
            SpawnerId  = spawnerId;

            SpawnSettings = new SpawnerConfig()
            {
                MasterIp   = connection.ConnectionIp,
                MasterPort = connection.ConnectionPort,
                MachineIp  = spawnerOptions.MachineIp,
                Region     = string.IsNullOrEmpty(spawnerOptions.Region) ? "International" : spawnerOptions.Region
            };

            // Add static handlers to listen one message for all controllers
            connection.SetHandler((short)MstMessageCodes.SpawnProcessRequest, SpawnProcessRequestHandler);
            connection.SetHandler((short)MstMessageCodes.KillProcessRequest, KillProcessRequestHandler);
        }
Example #10
0
        /// <summary>
        /// Changes the connection object, and sets all of the message handlers of this object
        /// to new connection.
        /// </summary>
        /// <param name="socket"></param>
        public void ChangeConnection(IClientSocket socket)
        {
            Connection = socket;

            // Override packet handlers
            foreach (var packetHandler in _handlers.Values)
            {
                socket.SetHandler(packetHandler);
            }
        }
Example #11
0
        public RoomController(int roomId, IClientSocket connection, RoomOptions options)
        {
            Logger = Msf.Create.Logger(typeof(RoomController).Name, LogLevel.Warn);

            Connection = connection;
            RoomId     = roomId;
            Options    = options;

            // Add handlers
            connection.SetHandler((short)MsfMessageCodes.ProvideRoomAccessCheck, ProvideRoomAccessCheckHandler);
        }
 // Use this for initialization
 protected virtual void Awake()
 {
     localSingleton = this;
     _items         = new GenericUIList <GameInfoPacket>(ItemPrefab.gameObject, LayoutGroup, ItemPrefab.transform.parent);
     ClientUIOverlord.onUIStateChanged += (ClientUIStates newState) => { if (newState == ClientUIStates.GameLobby)
                                                                         {
                                                                             resetSelection();
                                                                         }
     };
     Connection.SetHandler((short)ServerCommProtocl.LobbyGameStats, handleGameStatsUpdate);
 }
Example #13
0
        public RoomController(RoomsPlugin owner, int roomId, IClientSocket connection, RoomOptions options)
        {
            _roomsPlugin = owner;

            Connection = connection;
            RoomId     = roomId;
            Options    = options;

            // Add handlers
            connection.SetHandler((short)OpCodes.ProvideRoomAccessCheck, HandleProvideRoomAccessCheck);
        }
Example #14
0
        public SpawnerController(SpawnerPlugin owner, int spawnerId, IClientSocket connection, SpawnerOptions options)
        {
            _spawners = owner;

            Connection = connection;
            SpawnerId  = spawnerId;
            Options    = options;

            DefaultSpawnerSettings = new DefaultSpawnerConfig()
            {
                MasterIp         = connection.ConnectionIp,
                MasterPort       = connection.ConnectionPort,
                MachineIp        = options.MachineIp,
                SpawnInBatchmode = CommandLineArgs.IsProvided("-batchmode")
            };

            // Add handlers
            connection.SetHandler((short)OpCodes.SpawnRequest, HandleSpawnRequest);
            connection.SetHandler((short)OpCodes.KillSpawnedProcess, HandleKillSpawnedProcessRequest);
        }
Example #15
0
        public SpawnRequestController(SpawnRequestPlugin owner, int spawnId, IClientSocket connection, Dictionary <string, string> spawnOptions)
        {
            _spawnServer = owner;

            _connection  = connection;
            SpawnId      = spawnId;
            SpawnOptions = spawnOptions;

            // Set handlers
            connection.SetHandler((short)OpCodes.SpawnRequestStatusChange, HandleStatusUpdate);
        }
Example #16
0
        /// <summary>
        /// Changes the connection object, and sets all of the message handlers of this object
        /// to new connection.
        /// </summary>
        /// <param name="socket"></param>
        public void ChangeConnection(IClientSocket socket)
        {
            // Clear just connection but not handlers
            ClearConnection(false);

            // Change connections
            Connection = socket;

            // Override packet handlers
            foreach (var packetHandler in handlers.Values)
            {
                socket.SetHandler(packetHandler);
            }

            Connection.OnStatusChangedEvent += OnConnectionStatusChanged;
            OnConnectionSocketChanged(Connection);
        }
Example #17
0
    private void StartClient()
    {
        if (UseWs)
        {
            _client = new ClientSocketWs();
        }
        else
        {
            _client = new ClientSocketUnet();
        }

        _client.Connected    += Connected;
        _client.Disconnected += Disconnected;
        _client.SetHandler(new PacketHandler(_messageOpCode, HandleMessage));

        Debug.Log("Client: Trying to connect to " + ServerIpAddress + ":" + Port);
        _client.Connect(ServerIpAddress, Port);
    }
Example #18
0
        public JoinedLobby(LobbyDataPacket data, IClientSocket connection)
        {
            _connection = connection;
            Data        = data;
            connection.SetHandler((short)MstMessageCodes.LobbyMemberPropertyChanged, HandleMemberPropertyChanged);
            connection.SetHandler((short)MstMessageCodes.LeftLobby, HandleLeftLobbyMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyChatMessage, HandleLobbyChatMessageMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberJoined, HandleLobbyMemberJoinedMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberLeft, HandleLobbyMemberLeftMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyStateChange, HandleLobbyStateChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyStatusTextChange, HandleLobbyStatusTextChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberChangedTeam, HandlePlayerTeamChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberReadyStatusChange, HandleLobbyMemberReadyStatusChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMasterChange, HandleLobbyMasterChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyPropertyChanged, HandleLobbyPropertyChanged);

            Properties = data.LobbyProperties;
            Members    = data.Players;
            Teams      = data.Teams;
        }
Example #19
0
 public ChatPlugin(IClientSocket connection) : base(connection)
 {
     connection.SetHandler((short)OpCodes.UserJoinedChannel, HandleUserJoinedChannel);
     connection.SetHandler((short)OpCodes.UserLeftChannel, HandleUserLeftChannel);
     connection.SetHandler((short)OpCodes.ChatMessage, HandleChatMessage);
 }