Beispiel #1
0
        public virtual void Send(byte[] packet)
        {
            isSending.WaitOne();
            this.isConnecting.WaitOne();

            if (this.socket.Connected)
            {
                this.socket.BeginSend(packet, 0, packet.Length, SocketFlags.None, new AsyncCallback(x =>
                {
                    YMSGConnection yc = x.AsyncState as YMSGConnection;
                    int bytesSent     = yc.socket.EndSend(x);
                    yc.OnNotify(new YMSGNotification(bytesSent.ToString(), null)
                    {
                        NotificationType = YMSGNotificationTypes.BytesSent
                    });
                    yc.isSending.Set();
                }), this);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string userName, passwd;
            YMSGClient client = new YMSGClient();
            using (YMSGConnection yc = new YMSGConnection("scs.msg.yahoo.com", 5050))
            {
                yc.Subscribe(client);

                Console.WriteLine("Username: "******"Password: "******"You're logged in as {0}. This is a test client and supports the following commands.", yc.LoginName);
                Console.WriteLine("/pm <username> <message>");
                Console.WriteLine("/quit");
                while (true)
                {
                    string cmd = Console.ReadLine();
                    try
                    {
                        if (cmd.Substring(1, 2) == "pm")
                            yc.SendPM(cmd.Split(' ')[1], string.Join(" ", cmd.Split(' ').Skip(2).ToArray()));
                        else if (cmd.Substring(1, 4) == "quit")
                            break;
                        else
                            Console.WriteLine("Unknown Command.");
                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("Unknown Command.");
                    }
                }
            }
        }