Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            NIMEventInfo info = new NIMEventInfo();
            int          type = 0;

            int.TryParse(textBox1.Text, out type);
            int value = 0;

            int.TryParse(textBox2.Text, out value);
            long period = 0;

            long.TryParse(textBox3.Text, out period);
            int broadcastType = 0;

            int.TryParse(textBox4.Text, out broadcastType);
            int sync = 0;

            int.TryParse(textBox5.Text, out sync);
            info.Type           = type;
            info.Value          = value;
            info.ValidityPeriod = period;
            info.BroadcastType  = broadcastType;
            info.Sync           = sync;

            //info.Config = string.Format("event config - {0}", DateTime.Now.ToLongTimeString());
            info.ClientMsgID = Guid.NewGuid().ToString();
            info.NimConfig   = "online";
            //info.NimConfig.OnlineClients = new List<int>() { 1, 2, 4 };

            NIM.NIMSubscribeApi.Publish(info, OnPublishCompleted);
        }
Ejemplo n.º 2
0
 private void OnSubscribedEventChanged(ResponseCode code, NIMEventInfo info)
 {
     this.Invoke(new Action(() =>
     {
         int state = 0;
         if (code == ResponseCode.kNIMResSuccess)
         {
             //在线状态事件
             if (info.Type == 1)
             {
                 //获取在线客户端列表
                 var t = NimUtility.Json.JsonParser.Deserialize <OnlineEvent>(info.NimConfig);
                 if (t != null && t.Clients.Count > 0)
                 {
                     state = 1;
                 }
             }
             UpdateFriendLoginState(info.PublisherID, state);
         }
     }));
 }
Ejemplo n.º 3
0
 private void OnPublishCompleted(ResponseCode code, NIMEventInfo info)
 {
     NimUtility.Log.Info(string.Format("[OnPublishCompleted :code = {0},info:{1}]", code, info.Dump()));
 }
Ejemplo n.º 4
0
 private void PushEventCallback(ResponseCode code, NIMEventInfo info)
 {
     NimUtility.Log.Info(string.Format("[PushEventCallback code = {0},infoList:{1}]", info.Dump()));
 }