/// <summary> /// States the fault. /// </summary> /// <param name="event">The event.</param> private void State_Fault(State_Event @event) { switch (@event) { case State_Event.Enter: delay = 0; this.SetPlcData(string.Empty); if (this.tcpClient != null) { this.tcpClient.Connected -= this.TcpClient_Connected; this.tcpClient.Disconnected -= this.TcpClient_Disconnected; this.tcpClient.DataAvailable -= this.TcpClient_DataAvailable; } this.tcpClient?.Disconnect(); this.tcpClient?.Dispose(); this.tcpClient = null; this.UpdateStatus(GuiState.FAULT, Invariant($"{this.Name} is in fault.")); break; case State_Event.Poll: delay++; if (delay > 10) { this.StateTrans(PlcState.State_GetPort, this.State_GetPort); } break; default: break; } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { base.Dispose(disposing); if (!this.isDisposed) { if (disposing) { if (this.tcpClient != null) { this.tcpClient.Connected -= this.TcpClient_Connected; this.tcpClient.Disconnected -= this.TcpClient_Disconnected; this.tcpClient.DataAvailable -= this.TcpClient_DataAvailable; // Poll timer is killed by now if (this.tcpClient.IsConnected) { this.logger.Information(Invariant($"{Red}Disconnecting from PLC {this.Name}")); this.tcpClient.Disconnect(); } } this.tcpClient?.Dispose(); this.tcpClient = null; this.plcTxFifo = null; } this.isDisposed = true; } }
// Team Red = 1 // Team Blue = 2 // TO DO: Where the Client has to be spawned should be calculated in the NetworkManager public static void SendTeamSelected(int team) { if (team == 1) { string teamMessage = StartMenuUI.instanceUI.usernameField.text + " is connected to Team " + team; ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CTeamSelectedRed); buffer.WriteString(teamMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); StartMenuUI.instanceUI.TeamsitesUI.SetActive(true); } if (team == 2) { string teamMessage = StartMenuUI.instanceUI.usernameField.text + " is connected to Team " + team; ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CTeamSelectedBlue); buffer.WriteString(teamMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); StartMenuUI.instanceUI.UsernameUI.SetActive(false); StartMenuUI.instanceUI.TeamsitesUI.SetActive(true); } }
//TODO: Check Architecture Later private void SetReadyForMatch(Scene scene, LoadSceneMode mode) { if (scene.name == "Match") { ClientTCP.PACKAGE_SetReadyForMatch(currentMatchManager.matchID); } }
void Start() { clientConnection = new ClientTCP( ); //player = new Player ( ); clientConnection.RaiseDataFrameRecvd += HandleOnDataFrameRecvd; }
/// <summary> /// Take Damage Process /// </summary> /// <param name="c"></param> /// <param name="damage"></param> private void TakeDamageProcessFunc(TakeDamage d, ClientTCP c) { //둘중하나라도 죽었을경우 process return if (!PlayerDic[0].IsAlive || !PlayerDic[1].IsAlive) { return; } //클라넘버 int cn = d.ClientNum; PlayerDic[cn].Hp -= d.Damage; if (PlayerDic[cn].Hp == 0) { PlayerDic[cn].IsAlive = false; foreach (var cl in PlayerDic) { cl.Value.Client.Send(new Player_Dead((byte)cn)); } //Round 정리 //RoundProcess(c, cn); } c.Send(new Player_Sync((byte)cn, PlayerDic[cn].Hp)); }
public override string Run(JSONNode responseData) { var userId = (ushort)responseData["user_id"].AsInt; var token = responseData["token"].Value; var address = responseData["address"].Value; var port = responseData["port"].AsInt; if (userId < 1) { return("wrong user_id"); } if (token == "") { return("wrong token"); } ClientTCP.CurToken = token; ClientTCP.UserId = userId; var err = ClientTCP.ConnectToGame(address, port); if (err != null) { return(err); } ClientTCP.SendMsg(NET_CMD.SYNC, null); return(null); }
/// <summary> /// when GameRoom entry, Set Client Info /// </summary> /// <param name="c1"></param> /// <param name="c2"></param> public void SetClientInGameRoom(ClientTCP c1, ClientTCP c2) { //Send StartGame (MultiPort 보냄) 클라이언트가 인게임씬로드 하기위한 패킷 Console.WriteLine("multicast port" + multicastPortUDP); c1.Send(new Start_Game((ushort)multicastPortUDP, 0xEF0000B6)); c2.Send(new Start_Game((ushort)multicastPortUDP, 0xEF0000B6)); //TeamSet PlayerDic.Add((int)TeamColor.BLUE, c1.player); PlayerDic.Add((int)TeamColor.RED, c2.player); foreach (var player in PlayerDic) { if (player.Value.RoundPoint > 0) { player.Value.RoundPoint = 0; } } foreach (var team in PlayerDic) { var c = team.Value.Client; //Ingame Set c.ingame = true; //TCP Handler c.ProcessHandler += IngameDataRequestTCP; } SetClientVar(); }
private void LateUpdate() { if (PlayerConnectionId == ClientManager.instance.myConnectionId) { ClientTCP.SendMovement(transform.position, transform.rotation); } }
public void SetSelectedCardID(int cardID, string bodyPart) { selectedCardID = cardID; target = bodyPart; ClientTCP.PACKAGE_SendSelectedCard(matchID, selectedCardID, bodyPart); }
public void Update() { if (Input.GetKeyUp(KeyCode.R)) { ClientTCP.PACKAGE_SendRestartMatch(currentMatchID); } }
void Start() { DontDestroyOnLoad(this); UnityThread.initUnityThread(); ClientHandleData.InitializePackets(); ClientTCP.InitializingNetworking(); }
public static void Compose(Outbound packageIndex) { PacketBuffer buffer = new PacketBuffer(); buffer.Write(packageIndex); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
public void ConnectToServer() { Tcp = new ClientTCP(); Udp = new ClientUDP(); isConnected = true; Instance.Tcp.Connect(); }
void Start() { Debug.Log("Customnetworkmanager Start"); DontDestroyOnLoad(this); MainThreadDispatcher.Initialize(); ClientHandleData.InitializePackets(); ClientTCP.InitializingNetworking(); }
private void Awake() { DontDestroyOnLoad(this); UnityThread.initUnityThread(); ClientHandleData.InitializePacketListener(); ClientTCP.InitializeClientSocket(ipAddress, port); }
public handler() { client = new ClientTCP("127.0.0.1", 2502, this); client.Connect(); System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(input)); th.IsBackground = false; th.Start(); }
/// <summary> /// exit Player Remove /// </summary> /// <param name="c"></param> private void ClientRemove(ClientTCP c) { var cNumber = PlayerDic.FirstOrDefault(x => x.Value.Client == c).Key; PlayerDic.Remove(cNumber); //Test Room peopleCount--; c.CloseClient(); }
public HomePageModel(int numOfPics) { pics = numOfPics; if (pics < 0) { pics = -1; } client = ClientTCP.getInstance(); }
public static void SendHelloServer() { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInt((int)ClientPackets.CHelloServer); buffer.WriteString("I'am now connected to you!"); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
private void OnApplicationQuit() { if (!isOnline) { return; } ClientTCP.Disconnect(); }
public static void COtherPlayerHasTakenDamage(string serverMessage) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.COtherPlayerDamage); buffer.WriteString(serverMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
public static void CLocalPlayerDied(string serverMessage) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CPlayerDied); buffer.WriteString(serverMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
public static void CRocketHasBeenSpawned(string serverMessage) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CRocketHasBeenSpawned); buffer.WriteString(serverMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// add Gaemroom in List /// </summary> /// <param name="room"></param> public void CreateRoom(ClientTCP c1, ClientTCP c2) { var TmpRoom = new GameRoom(roomCount, 10000 + roomCount); roomDic.Add(roomCount, TmpRoom); roomDic[roomCount].SetClientInGameRoom(c1, c2); roomCount++; Console.WriteLine("[GAME ROOM MANAGER] : Add GameRoom !"); }
private void Awake() { instance = this; DontDestroyOnLoad(this); UnityThread.initUnityThread(); InitPlayers(); ClientHandleData.InitPackets(); ClientTCP.InitClient(IPAddress, Port); }
//If the Local Client (myself) wants to quit the Game public static void SendDisconnetOfLocalClient(string serverMessage) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CDisconnectClient); buffer.WriteString(serverMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
public static void SendMerhabaServer() { ByteBuffer buffer = new ByteBuffer(); buffer.Int_Yaz((int)ClientPackes.CMerhabaServer); buffer.String_Yaz("Huuuu ben geldimmmm"); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
public static void SendPlayerPosition(Vector3 position) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CPlayerPosition); buffer.WriteString(position.ToString()); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }
//The Client sends his Positon and Rotation to the Server, so the Server syncs the Data with every other Client on the Match public static void SendPositionClientToServer(string serverMessage) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInteger((int)ClientPackets.CLocationClient); buffer.WriteString(serverMessage); ClientTCP.SendData(buffer.ToArray()); buffer.Dispose(); }