public ServerSocket(string _ipAddressPort, ConnectMethod _connect = null, DisconnectMethod _disconnect = null, DecodePacketMethod _decodePacket = null, int _bufferSize = 1024, int _backLog = 100) { port = int.Parse(_ipAddressPort.Split(new char[] { ':' })[1]); connectMethod = _connect; disconnectMethod = _disconnect; decodePacketMethod = _decodePacket; bufferSize = _bufferSize; backLog = _backLog; }
public ServerSocket(int _port, ConnectMethod _connect = null, DisconnectMethod _disconnect = null, DecodePacketMethod _decodePacket = null, int _bufferSize = 1024, int _backLog = 100) { port = _port; connectMethod = _connect; disconnectMethod = _disconnect; decodePacketMethod = _decodePacket; bufferSize = _bufferSize; backLog = _backLog; }
public ClientSocket(string _ipAddressPort, ConnectMethod _connect = null, DisconnectMethod _disconnect = null, DecodePacketMethod _decodePacket = null, int _bufferSize = 1024) { ipAddress = _ipAddressPort.Split(new char[] { ':' })[0]; port = int.Parse(_ipAddressPort.Split(new char[] { ':' })[1]); connectMethod = _connect; disconnectMethod = _disconnect; decodePacketMethod = _decodePacket; bufferSize = _bufferSize; buffer = new byte[_bufferSize]; }
public ClientSocket(string _ipAddress, int _port, ConnectMethod _connect = null, DisconnectMethod _disconnect = null, DecodePacketMethod _decodePacket = null, int _bufferSize = 1024) { ipAddress = _ipAddress; port = _port; connectMethod = _connect; disconnectMethod = _disconnect; decodePacketMethod = _decodePacket; bufferSize = _bufferSize; buffer = new byte[_bufferSize]; }
/// <summary> /// Removes a player from this game. if disconnectFromServer == true, we'll assume player /// either did hard shutdown, or was dropped forcibly by the game because their connection timed out. /// In this case, we send cmd_forceDisconnect command to each client so they can get rid of that player's object. Otherwise, we'll just put them back in the hangar. /// </summary> /// <param name="tag">The tag of the player to remove.</param> /// <param name="keepOnServer">If true, this player will not be dropped from the server.</param> /// <param name="d">The method by which this player is being disconnected. If the player was disconnected because they lost, /// this flag should be set to gameEnd. Otherwise, if the player hit escape or was dropped, this flag should be set to midGame.</param> private void removeFromGame(String tag, bool keepOnServer, DisconnectMethod d) { if (clientList[tag].host) //If this is the game host, forceGameEnd = true; //If they drop or disconnect, end the game. Server.returnFromGame(tag, clientList[tag], keepOnServer); clientList.Remove(tag); //In case this is a case where the client was disconnected without an in-game event, //IE: a connection drop, tell all clients that this object has disconnected so they can //clean it up. propogate(CSCommon.buildCMDString(CSCommon.cmd_forceDisconnect, tag), null); if (clientList.Count == 0) canEvaluateGameEnd = true; modifiedClientList = true; if (type == GameType.freeForAll) clearBotsFromPlayer(tag); //now game is unbalanced, so call it quit since players may cheat this way, //by starting a team death, disconnecting, and the other team gets all the points. //Or if there's a death match and only one player remains after this disconnect, just end the game since one player in a deth match is pointless! if (type == GameType.teamDeath && d == DisconnectMethod.midGame || type == GameType.oneOnOne && clientList.Count == 1) forceGameEnd = true; }