internal AVGroup(string selfId, string groupId, AVSession session, EventHandler<EventArgs> onJoined, EventHandler<EventArgs> onLeft, EventHandler<AVGroupMembersJoinedEventArgs> onMembersJoined, EventHandler<AVGroupMembersLeftEventArgs> onMembersLeft)
   : this(selfId, groupId, session)
 {
     if (onJoined != null)
         this.OnJoined += onJoined;
     if (onLeft != null)
         this.OnLeft += onLeft;
     if (onMembersJoined != null)
         this.OnMembersJoined += onMembersJoined;
     if (onMembersLeft == null)
         return;
     this.OnMembersLeft += onMembersLeft;
 }
 internal AVGroup(string selfId, string groupId, AVSession session)
   : this(selfId, session)
 {
     this.GroupId = groupId;
 }
 internal AVGroup(string selfId, AVSession session)
   : this()
 {
     this.SelfId = selfId;
     this.Session = session;
     this.Session.OnGroupAction += new EventHandler<AVRtcGroupEventArgs>(this.Session_OnGroupAction);
 }
 private void checkSignature(AVSession session, IList<string> watchPeerIds, IDictionary<string, object> cmdBody)
 {
     if (session.SignatureFactory != null)
     {
         session.SignatureFactory.CreateSignature(session.SelfId, watchPeerIds)
             .ContinueWith((Action<Task<AVIMSignature>>) (x =>
             {
                 AVIMSignature result = x.Result;
                 if (result == null)
                     return;
                 cmdBody.Add("s", (object) result.SignatureContent);
                 cmdBody.Add("t", (object) result.Timestamp);
                 cmdBody.Add("n", (object) result.Nonce);
             })).ContinueWith((Action<Task>) (y => this.SendCMD(cmdBody)));
     }
     else
     {
         cmdBody.Add("s", (object) "");
         this.SendCMD(cmdBody);
     }
 }
 private void checkGroupSinature(AVSession session, string groupId, IList<string> targetPeerIds, string action,
     IDictionary<string, object> cmdBody)
 {
     if (session.SignatureFactory != null)
         session.SignatureFactory.CreateGroupSignature(groupId, session.SelfId, targetPeerIds, action)
             .ContinueWith((Action<Task<AVIMSignature>>) (x =>
             {
                 AVIMSignature result = x.Result;
                 if (result == null)
                     return;
                 cmdBody.Add("s", (object) result.SignatureContent);
                 cmdBody.Add("t", (object) result.Timestamp);
                 cmdBody.Add("n", (object) result.Nonce);
             })).ContinueWith((Action<Task>) (y => this.SendCMD(cmdBody)));
     else
         this.SendCMD(cmdBody);
 }
 public void RemovePeersFromGroup(AVSession session, AVGroup group, IList<string> peerIds)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "room");
     cmdBody.Add("op", (object) "kick");
     if (!string.IsNullOrEmpty(group.GroupId))
         cmdBody.Add("roomId", (object) group.GroupId);
     cmdBody.Add("roomPeerIds", (object) peerIds);
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     this.checkGroupSinature(session, group.GroupId == null ? string.Empty : group.GroupId, peerIds, "kick",
         cmdBody);
 }
 public void LeftFromGroup(AVSession session, AVGroup group)
 {
     this.checkGroupSinature(session, group.GroupId, (IList<string>) null, "leave",
         (IDictionary<string, object>) new Dictionary<string, object>()
         {
             {
                 "cmd",
                 (object) "room"
             },
             {
                 "op",
                 (object) "leave"
             },
             {
                 "peerId",
                 (object) session.SelfId
             },
             {
                 "roomId",
                 (object) group.GroupId
             },
             {
                 "appId",
                 (object) AVClient.ApplicationId
             }
         });
 }
 public void UnWatchPeers(AVSession session, IList<string> peerIds)
 {
     string key = Guid.NewGuid().ToString();
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "session");
     cmdBody.Add("op", (object) "remove");
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     cmdBody.Add("i", (object) key);
     cmdBody.Add("sessionPeerIds", (object) peerIds);
     this.SendCMD(cmdBody);
     AVSessionOp avSessionOp = new AVSessionOp()
     {
         id = key,
         op = "removed"
     };
     avSessionOp.data = (IDictionary<string, object>) new Dictionary<string, object>();
     avSessionOp.data.Add("ToRemovePeerIds", (object) peerIds);
     session.pendingSessionChanged.Add(key, avSessionOp);
 }
 public void CreateGroup(AVSession session)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "room");
     cmdBody.Add("op", (object) "join");
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     this.checkGroupSinature(session, string.Empty, (IList<string>) null, "join", cmdBody);
 }
 public void SendMessage(AVSession session, AVGroup group, AVMessage message)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "direct");
     cmdBody.Add("msg", (object) message.Message);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     cmdBody.Add("roomId", (object) group.GroupId);
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("fromPeerId", (object) session.SelfId);
     cmdBody.Add("id", (object) message.localId);
     this.SendCMD(cmdBody);
 }
 public void SendMessage(AVSession session, AVMessage message)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "direct");
     cmdBody.Add("msg", (object) message.Message);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("toPeerIds", (object) message.ToPeerIds);
     cmdBody.Add("transient", (message.IsTransient ? 1 : 0));
     cmdBody.Add("id", (object) message.localId);
     this.SendCMD(cmdBody);
 }
 public void CloseSession(AVSession session)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "session");
     cmdBody.Add("op", (object) "close");
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     this.SendCMD(cmdBody);
 }
 public void OpenSession(AVSession session, IList<string> watchPeerIds)
 {
     IDictionary<string, object> cmdBody = (IDictionary<string, object>) new Dictionary<string, object>();
     cmdBody.Add("cmd", (object) "session");
     cmdBody.Add("op", (object) "open");
     cmdBody.Add("peerId", (object) session.SelfId);
     cmdBody.Add("appId", (object) AVClient.ApplicationId);
     if (watchPeerIds != null)
         cmdBody.Add("sessionPeerIds", (object) watchPeerIds);
     if (this.connected)
     {
         this.checkSignature(session, watchPeerIds, cmdBody);
     }
     else
     {
         this.OnWebSocketOpend +=
             (EventHandler<WebSoceketOpenEventArgs>)
                 ((sender, e) => this.checkSignature(session, watchPeerIds, cmdBody));
         this.Initialize();
     }
 }
 private void OnPeerOffline(AVSession session, List<string> peerIds)
 {
     lock (this.mutex)
     {
         foreach (string item_0 in peerIds)
         {
             if (this.OnlinePeerIds.Contains(item_0))
                 this.OnlinePeerIds.Remove(item_0);
         }
     }
     if (this.AVSessionListener.OnStatusOffline == null)
         return;
     this.AVSessionListener.OnStatusOffline(session, (IList<string>)peerIds);
 }