public override void Tick(object state) { base.Tick(state); if (OwnTcpSocket == null || !OwnTcpSocket.Connected) { return; } if (OwnTcpSocket.Available > 0) { int length = OwnTcpSocket.Client.Receive(databuffer); byte[] vs = new byte[length]; Buffer.BlockCopy(databuffer, 0, vs, 0, length); DebugLogging("Tcp Received : " + encoding.GetString(vs)); DecompServerMessage(vs); if (OnTcpPacketReceived != null) { OnTcpPacketReceived.Invoke(vs); } } if (FTContainer.FTSocket.Available > 0) { databuffer = new byte[FTContainer.FTSocket.Client.ReceiveBufferSize]; int length = FTContainer.FTSocket.Client.Receive(databuffer); byte[] trimmeddata = new byte[length]; Buffer.BlockCopy(databuffer, 0, trimmeddata, 0, length); //DebugLogging("FTP Received : " + encoding.GetString(trimmeddata)); ProcessFileTransmissionInfo(trimmeddata); } if (OwnUdpClient.Available > 0) { IPEndPoint endPoint = null; byte[] Udpdatabuffer = OwnUdpClient.Receive(ref endPoint); DecompReplicationData(Udpdatabuffer); if (OnUdpPacketReceived != null) { OnUdpPacketReceived.Invoke(Udpdatabuffer); } } ReplicateAutonomousObject(); }
/// <summary> /// manually call is not recommended /// </summary> public override void Tick(object state) { base.Tick(state); if (ClientDataList.Count < 1) { return; } try { ClientDataList.ForEach((c) => { if (c.TcpSocket.Available > 0) { int dleng = c.TcpSocket.Client.Receive(buffer); byte[] vs = new byte[dleng]; Buffer.BlockCopy(buffer, 0, vs, 0, dleng); DebugLogging("Tcp Received : " + encoding.GetString(vs)); DecompClientRequest(vs, c); if (OnTcpPacketReceived != null) { OnTcpPacketReceived.Invoke(vs, c); } } }); FTSocketsList.ForEach((ft) => { if (ft.FTSocket.Available > 0) { buffer = new byte[ft.FTSocket.Client.ReceiveBufferSize]; int length = ft.FTSocket.Client.Receive(buffer); byte[] trimmeddata = new byte[length]; Buffer.BlockCopy(buffer, 0, trimmeddata, 0, length); //DebugLogging("FTP Received : " + encoding.GetString(trimmeddata)); ProcessFileTransmissionInfo(trimmeddata, ft); } }); } catch (Exception ex) { DebugLogging(ex.Message + " " + ex.StackTrace); } if (UdpSocket.Available > 0) { try { IPEndPoint endPoint = null; byte[] Udpbuffer = UdpSocket.Receive(ref endPoint); string strdata = encoding.GetString(Udpbuffer); ClientDataContainer_ForTool client = ClientDataList.Find((c) => c.address.ToString() == endPoint.Address.ToString()); DebugLogging("Udp Received : " + strdata + " " + endPoint.Address + " " + endPoint.Port + " " + client.NetworkId); if (strdata == "InitRep$") { client.UdpEndPoint = endPoint.Port; DebugLogging("Client UDP Assign : " + client.UserName + " " + client.address.ToString() + " " + client.UdpEndPoint + " ID: " + client.NetworkId); } DecompClientReplicationData(Udpbuffer, client); OnUdpPacketReceived?.Invoke(Udpbuffer, client); } catch (Exception ex) { DebugLogging(ex.Message + " " + ex.StackTrace); } } Replicate(); }