public bool SendMessage(Header header, object data) { byte[] sendData = PacketDefine.MakePacket(header, data); stream.Write(sendData, 0, sendData.Length); return(true); }
public bool SendMessage(Header header, object data, Socket EndPointServerSocket) { byte[] sendData = PacketDefine.MakePacket(header, data); if (!this.ClientSocket.IsBound) { return(false); } EndPointServerSocket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, new AsyncCallback(SendMessage2), EndPointServerSocket); //this.ClientSocket.Send(sendData); return(true); }
//메시지 전달 private bool SendMessage(short id, int value) { MatchingData message = new MatchingData(); message.MessageID = (byte)MessageID.IndianPokser; message.Ack = 1; message.matchingMsg = (byte)Matching.StartMatching; byte[] sendMessage = packetDefine.MakePacket(message); stream.Write(sendMessage, 0, sendMessage.Length); return(true); //a //a //string msg = "matching"; //byte[] header = BitConverter.GetBytes(id); //byte[] body = BitConverter.GetBytes(value); //int length = header.Length + body.Length; //byte[] leng = BitConverter.GetBytes(length); //byte[] packet = new byte[length+sizeof(int)]; //Array.Copy(header, 0, packet, 0, header.Length); //Array.Copy(leng, 0, packet, header.Length, leng.Length); //Array.Copy(body, 0, packet, header.Length + leng.Length, body.Length); //try //{ // stream.Write(packet, 0, packet.Length); // stream.Flush(); // return true; //} //catch //{ // Console.WriteLine("메시지 전송 실패"); // return false; //} }
public void SendMessage(Header header, object data, Socket EndPointClientSocket) { byte[] sendData = PacketDefine.MakePacket(header, data); EndPointClientSocket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, new AsyncCallback(SendMessage2), EndPointClientSocket); }