public void Transpond(string clientStr) { Package pk = new Package(); string[] str = clientStr.Split('|'); Room room = funcGetRoomByRoomId(Convert.ToInt32(str[0])); if (room.hostSock == this.sokMsg) { byte[] byteStr = pk.PackStr(clientStr.Substring(str[0].Length - 1)); room.payerSock.Send(byteStr); } else { byte[] byteStr = pk.PackStr(clientStr.Substring(str[0].Length - 1)); room.hostSock.Send(byteStr); } }
/// <summary> /// 向客户端发送消息 /// </summary> /// <param name="strMsg"></param> public void Send(string strMsg) { //byte[] arrMsg = System.Text.Encoding.UTF8.GetBytes(strMsg); //byte[] arrMsgFinal = new byte[arrMsg.Length + 1]; //arrMsgFinal[0] = 0;//设置 数据标识位等于0,代表 发送的是 文字 //arrMsg.CopyTo(arrMsgFinal, 1); //sokMsg.Send(arrMsgFinal); Package pk = new Package(); sokMsg.Send(pk.PackStr(strMsg)); }