public void SendMessage(AVMessage message, EventHandler<AVGroupMessageSentEventArgs> onGroupMessageSent, EventHandler<AVGroupMessageReceivedEventArgs> onGroupMessageRecevied) { if (onGroupMessageSent != null) { this.OnGroupMessageSent += onGroupMessageSent; this.Session.OnMessageSent += (this.Session_OnMessageSent); } if (onGroupMessageRecevied != null) { this.OnMessage += onGroupMessageRecevied; this.Session.OnMessage += (this.Session_OnMessage); } this.Session.SendMessage(this, message); }
public void SendMessage(string msg, EventHandler<AVGroupMessageSentEventArgs> onGroupMessageSent, EventHandler<AVGroupMessageReceivedEventArgs> onGroupMessageRecevied) { AVMessage message = new AVMessage(); message.FromPeerId = this.Session.SelfId; message.GroupId = this.GroupId; string str = Guid.NewGuid().ToString(); message.localId = str; message.Message = msg; message.Timestamp = AVPersistence.GetCurrentUnixTimestampFromDateTime(); this.SendMessage(message, onGroupMessageSent, onGroupMessageRecevied); }
private AVIMEventArgs ProcessAVMessage(IDictionary<string, object> data) { AVMessage avMessage = new AVMessage(); avMessage.FromPeerId = AVRMProtocolUtils.CaptureValueFromDictionary<string>(data, "fromPeerId"); avMessage.IsTransient = AVRMProtocolUtils.CaptureValueFromDictionary<bool>(data, "transient"); avMessage.Message = AVRMProtocolUtils.CaptureValueFromDictionary<string>(data, "msg"); avMessage.ToPeerIds = (IList<string>) new List<string>(); string peerId = AVRMProtocolUtils.CaptureValueFromDictionary<string>(data, "peerId"); avMessage.ToPeerIds.Add(peerId); avMessage.GroupId = AVRMProtocolUtils.CaptureValueFromDictionary<string>(data, "roomId"); avMessage.Id = AVRMProtocolUtils.CaptureValueFromDictionary<string>(data, "id"); avMessage.Timestamp = AVRMProtocolUtils.CaptureValueFromDictionary<long>(data, "timestamp"); this.SendAckCMD(peerId, avMessage.Id); return new AVIMEventArgs() { Message = avMessage }; }
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 SendMessage(AVGroup group, AVMessage message) { this.DoActionAfterSessionOpen((Action)(() => { lock (this.mutex) this.pendingMeaasge.Add(message.localId, message); this.rtc.SendMessage(this, group, message); })); }
public void SendMessage(string msg, IList<string> toPeers, bool transient, EventHandler<AVMessageReceivedEventArgs> onMessage) { if (onMessage != null) this.m_OnMessage += onMessage; if (this.Status == SessionStatus.Opend) { AVMessage message = new AVMessage(); string key = Guid.NewGuid().ToString(); message.localId = key; message.Message = msg; message.Timestamp = AVPersistence.GetCurrentUnixTimestampFromDateTime(); message.FromPeerId = this.SelfId; message.ToPeerIds = toPeers; lock (this.mutex) this.pendingMeaasge.Add(key, message); this.rtc.SendMessage(this, message); } else { if (this._avSessionListener.OnMessageFailure == null) return; this._avSessionListener.OnMessageFailure(this, new AVMessage() { Message = msg, FromPeerId = this.SelfId, ToPeerIds = toPeers }, new AVIMError() { Code = AVException.ErrorCode.CanNotSendMessageOnSessionNotOpen }); } }