コード例 #1
0
 public void Send(Protocol.IMessage message, Beetle.Express.IChannel channel)
 {
     if (channel != null)
     {
         Application.Server.Send(message, channel);
     }
 }
コード例 #2
0
        public void OnLogin(Beetle.Express.IChannel channel, string id, string command, JToken token)
        {
            channel.Name = token["name"].ToString();
            User user = new User();

            user.Name = channel.Name;
            user.ID   = channel.ID;
            user.Host = channel.EndPoint.ToString();
            SendAll(id, command, user);
        }
コード例 #3
0
        public void OnTalk(Beetle.Express.IChannel channel, string id, string command, JToken token)
        {
            string content = token["content"].ToString();
            Talk   talk    = new Talk();

            talk.Content = content;
            talk.From    = channel.Name;
            talk.Host    = channel.EndPoint.ToString();
            SendAll(id, command, talk);
        }
コード例 #4
0
        public void OnList(Beetle.Express.IChannel channel, string id, string command, JToken token)
        {
            List <User> users = new List <User>();

            Server.GetOnlines(Onlines);
            for (int i = 0; i < Onlines.Count; i++)
            {
                Beetle.Express.IChannel client = Onlines.Channels[i];
                users.Add(new User {
                    Host = client.EndPoint.ToString(), ID = client.ID, Name = client.Name
                });
            }
            SendAll(id, command, users);
        }
コード例 #5
0
 public void Init(EC.IApplication application)
 {
     application.Disconnected += (o, e) =>
     {
         Beetle.Express.IChannel channel = e.Session.Channel;
         Chat.Signout            msg     = new Signout();
         msg.Name = channel.Name;
         msg.From = channel.EndPoint.ToString();
         foreach (Beetle.Express.IChannel other in application.Server.GetOnlines())
         {
             if (other != channel)
             {
                 application.Server.Send(msg, other);
             }
         }
     };
 }
コード例 #6
0
        public void Search(Beetle.Express.IChannel channel, string id, string command, JToken token)
        {
            int          size      = 10;
            int          pageindex = token["pageindex"].ToObject <int>();
            SearchResult result    = new SearchResult();

            result.Pages = mCustomers.Count / size;
            if (mCustomers.Count % size > 0)
            {
                result.Pages++;
            }
            for (int i = pageindex * size; i < mCustomers.Count; i++)
            {
                result.Items.Add(mCustomers[i]);
                if (result.Items.Count >= size)
                {
                    break;
                }
            }
            Send(channel, id, command, result);
        }
コード例 #7
0
 protected override void ReceivePacket(Beetle.Express.IChannel channel, Beetle.Express.WebSockets.IPacketData data)
 {
     base.ReceivePacket(channel, data);
     Console.WriteLine(data.Data.Decoding());
 }
コード例 #8
0
        public void OnList(Beetle.Express.IChannel channel, string id, string command, JToken token)
        {
            string result = "hello " + token.ToString();

            Send(channel, id, command, result);
        }