/// <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); }); }
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); }
/// <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); }
public RoomController(int roomId, IClientSocket connection, RoomOptions options) { Connection = connection; RoomId = roomId; Options = options; // Add handlers connection.SetHandler((short)MsfOpCodes.ProvideRoomAccessCheck, HandleProvideRoomAccessCheck); }
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); }
/// <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); }
/// <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); } }
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); }
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); }
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); }
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); }
/// <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); }
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); }
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; }
public ChatPlugin(IClientSocket connection) : base(connection) { connection.SetHandler((short)OpCodes.UserJoinedChannel, HandleUserJoinedChannel); connection.SetHandler((short)OpCodes.UserLeftChannel, HandleUserLeftChannel); connection.SetHandler((short)OpCodes.ChatMessage, HandleChatMessage); }