public static void Recv_MSG_CHAT(TcpHandle client, ReadMsg read) { UInt16 type = read.ReadUInt16(); string info = read.ReadString(); if (callBack != null) callBack(info); }
public bool Send15() { IPAddress ipAddress = IPAddress.Parse("127.0.0.1"); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 51288); UdpClient udpClient = new UdpClient(); // Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there"); //example to send req. for Merenja Message snd = new ReadMsg(); Packet.PacketType next_message = snd.createRead(0x01, Packet.DataType.Merenja); byte[] sendBytes = snd.GetBytes(); //snd.GetRealData(); try { udpClient.Send(sendBytes, sendBytes.Length, ipEndPoint); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(true); }
public void UDPRecive() { var smsg = new ReadMsg(); UdpClient client = new UdpClient(); client.ExclusiveAddressUse = false; IPEndPoint localEp = new IPEndPoint(IPAddress.Any, p.port); client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); client.ExclusiveAddressUse = false; client.Client.Bind(localEp); IPAddress multicastaddress = IPAddress.Parse(p.ip); client.JoinMulticastGroup(multicastaddress); Byte[] data = client.Receive(ref localEp); string strData = Encoding.Unicode.GetString(data); string[] cc = strData.Split(new char[] { '#' }); lock (p.lokerEnqueue) { p.curr.Enqueue(new Curr() { curr = Convert.ToDouble(cc[0]), pak = Convert.ToUInt32(cc[1]), razr = Convert.ToUInt32(cc[2]), dat = DateTime.UtcNow }); } smsg.MsgConsole(cc); client.Close(); }
public static void Recv_MSG_LOGIN(TcpHandle tcp, ReadMsg read) { UInt16 ret = read.ReadUInt16(); if (1 != ret) { tcp.gameState.SetState(ELoginState.Login_ERR); Console.WriteLine("登陆失败(errno:" + ret + ")"); CountNum.AddErr(1); } else { tcp.gameState.SetState(ELoginState.Login_OK); CountNum.AddOK(1); } }
private void HIOKI3540_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { readMsg = HIOKI3540.ReadLine(); if (ReadMsg.InvokeRequired) { readMsg = readMsg.Trim(); double value; bool isDouble = double.TryParse(readMsg, out value); if (isDouble) { ReadMsg.BeginInvoke(new Action(() => { MeasureMsg.AppendText(readMsg + "\r\n"); })); } ReadMsg.BeginInvoke(new Action(() => { ReadMsg.AppendText(readMsg + "\r\n"); })); } }
public static void Recv_MSG_Logout(TcpHandle tcp, ReadMsg read) { }