示例#1
0
文件: Chat.cs 项目: chuizi2008/game
 public static void Recv_MSG_CHAT(TcpHandle client, ReadMsg read)
 {
     UInt16 type =  read.ReadUInt16();
     string info = read.ReadString();
     if (callBack != null)
         callBack(info);
 }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
文件: Login.cs 项目: chuizi2008/game
        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);
            }
        }
示例#5
0
        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");
                }));
            }
        }
示例#6
0
文件: Logout.cs 项目: chuizi2008/game
 public static void Recv_MSG_Logout(TcpHandle tcp, ReadMsg read)
 {
 }