public void SendRanking() { StreamReader reader = new StreamReader("server.txt"); var serverIp = reader.ReadLine(); reader.Close(); // 서버에 매칭 요청을 함. IPEndPoint serverEndpoint_IP = new IPEndPoint(IPAddress.Parse(serverIp), CS_PORT); EndPoint targetEndPoint = (EndPoint)serverEndpoint_IP; Socket udpClient_server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); udpClient_server.ReceiveTimeout = 5000; udpClient_server.SendTimeout = 5000; CM_UpdateRanking myMsg = new CM_UpdateRanking(); myMsg.name = name; myMsg.score = lastKda; byte[] newMsg = MyTool.StructToBytes <CM_UpdateRanking>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTSType.UpdateRanking; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } udpClient_server.SendTo(newBuf, targetEndPoint); udpClient_server.Close(); }
private void SendToServer(byte[] msg) { cnm.third = cnm.second; cnm.second = cnm.first; cnm.first = msg; cnm.first_id = (cnm.first_id + 1 > 100000) ? 1 : cnm.first_id + 1; udpClient.SendTo(MyTool.StructToBytes <ClientNetworkMessage>(cnm), targetEndPoint); }
public void SendPosition(Vector3 position, Vector3 velocity) { CM_UpdatePosition myMsg = new CM_UpdatePosition(); myMsg.position = position; myMsg.velocity = velocity; byte[] newMsg = MyTool.StructToBytes <CM_UpdatePosition>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTCType.UpdatePosition; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } networkSendList.Add(newBuf); }
public void SendDeath(CharacterType type, Vector3 position) { CM_NoticeDeath myMsg = new CM_NoticeDeath(); myMsg.characterType = type; myMsg.position = position; byte[] newMsg = MyTool.StructToBytes <CM_NoticeDeath>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTCType.NoticeDeath; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } networkSendList.Add(newBuf); }
public void SendAttack(CharacterType type, int damage) { CM_AttackSuccess myMsg = new CM_AttackSuccess(); myMsg.type = type; myMsg.damage = damage; byte[] newMsg = MyTool.StructToBytes <CM_AttackSuccess>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTCType.AttackSuccess; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } networkSendList.Add(newBuf); }
public void SendUseSkill(int type, Vector3 position, Quaternion rotation) { CM_UseSkill myMsg = new CM_UseSkill(); myMsg.skillType = type; myMsg.position = position; myMsg.rotation = rotation; byte[] newMsg = MyTool.StructToBytes <CM_UseSkill>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTCType.UseSkill; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } networkSendList.Add(newBuf); }
public void SendTime() { if (currentState != ClientNetworkState.InGame) { return; } CM_SendTime myMsg = new CM_SendTime(); myMsg.timer = GameMain.GetInstance().timer; myMsg.dateTime = DateTime.Now.ToString(); byte[] newMsg = MyTool.StructToBytes <CM_SendTime>(myMsg); byte[] newBuf = new byte[newMsg.Length + 1]; newBuf[0] = (byte)CTCType.SendTime; for (int i = 0; i < newMsg.Length; ++i) { newBuf[i + 1] = newMsg[i]; } networkSendList.Add(newBuf); Invoke("SendTime", 5f); }