public void _Reg() { mainCtrl.GetSocket().Connect("127.0.0.1", 9190); MyUserName = _username.text + '\0'; MyUserNameLeng = MyUserName.Length; MyPassword = _password.text + '\0'; MyPasswordLeng = MyPassword.Length; int tempSendLen = (sizeof(int) * 4 + MyUserNameLeng + MyPasswordLeng); byte[] tempSendBuf = new byte[4096]; Buffer.BlockCopy(BitConverter.GetBytes(tempSendLen), 0, tempSendBuf, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(Protocol.PT_REG_USER), 0, tempSendBuf, sizeof(int), sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(MyUserNameLeng), 0, tempSendBuf, sizeof(int) * 2, sizeof(int)); Buffer.BlockCopy(Encoding.UTF8.GetBytes(MyUserName), 0, tempSendBuf, sizeof(int) * 3, MyUserNameLeng); Buffer.BlockCopy(BitConverter.GetBytes(MyPasswordLeng), 0, tempSendBuf, sizeof(int) * 3 + MyUserNameLeng, sizeof(int)); Buffer.BlockCopy(Encoding.UTF8.GetBytes(MyPassword), 0, tempSendBuf, sizeof(int) * 4 + MyUserNameLeng, MyPasswordLeng); mainCtrl.GetSocket().Send(tempSendBuf, tempSendLen, 0); mainCtrl.SetUserName(MyUserName); mainCtrl.RecvStart(); }
public void OnClickRoomEnter(Button m_button) { int tempSendLen = (sizeof(int) * 3); byte[] tempSendBuf = new byte[4096]; Buffer.BlockCopy(BitConverter.GetBytes(tempSendLen), 0, tempSendBuf, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(Protocol.PT_ROOM_ENTER), 0, tempSendBuf, sizeof(int), sizeof(int)); for (int i = 0; i < 6; i++) { if (roomList[i] == m_button) { Buffer.BlockCopy(BitConverter.GetBytes(i), 0, tempSendBuf, sizeof(int) * 2, sizeof(int)); mainCtrl.GetSocket().Send(tempSendBuf, tempSendLen, 0); } } }
public void OnClickSend() { string message = inputsend.text; int messageLeng = message.Length; int tempSendLen = (sizeof(int) * 3) + messageLeng; byte[] tempSendBuf = new byte[4096]; Buffer.BlockCopy(BitConverter.GetBytes(tempSendLen), 0, tempSendBuf, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(Protocol.PT_USER_CHAT), 0, tempSendBuf, sizeof(int), sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(messageLeng), 0, tempSendBuf, sizeof(int) * 2, sizeof(int)); Buffer.BlockCopy(Encoding.UTF8.GetBytes(message), 0, tempSendBuf, sizeof(int) * 3, messageLeng); Debug.Log(mainCtrl.GetSocket().Send(tempSendBuf, tempSendLen, 0)); }