📄 dialog.cs
字号:
base.SendSipMessage(msg);
}
private void AsyncSendMessage(Message msg)
{
this.AsyncSendMessage(msg, false);
}
private void AsyncSendMessage(Message msg, bool autoReplay)
{
this.AsyncSendMessage(msg, autoReplay, this.CallId);
}
protected void AsyncSendMessage(Message msg, bool autoReplay, long callID)
{
SipRequest request = this.InnerCreateSipRequest("M", callID, this.NextCSeq);
request.Message.AddHeader(new SipcToHeader(this.To));
request.Message.AddHeader(new SipcContentTypeHeader(this.ContentTypeString));
request.Message.AddHeader(new SipcSupportedHeader("SaveHistory"));
if ((this.Status != DialogStatus.Invited) && (base.Owner.Configuration.UserSetting.LongSmsSetting == LongSMSSetting.Enable))
{
request.Message.AddHeader(new SipcEventHeader("CatMsg"));
}
if (this.ContentType == MessageContentType.TextPlain)
{
request.Message.Body = Imps.Utils.TagParser.TagParser.Create(msg.Content, true).Text;
}
else
{
request.Message.Body = msg.Content.ToString();
}
request.Context = msg;
request.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.sendMessage_req_FinalResponseReceived);
request.SendMessageFailed += new EventHandler<FailedEventArgs>(this, (IntPtr) this.req_SendMessageFailed);
request.WaitResponseTimeout += new EventHandler(this.req_WaitResponseTimeout);
if (autoReplay)
{
request.Message.Headers.Add(new SipcEventHeader("auto-reply"));
}
base.SendSipMessage(request);
this.WaitingMessageResponseCount++;
this.AddChatFriends();
this.UpdateRecentBuddies();
}
public Message AsyncSendMms(string msg)
{
throw new NotImplementedException();
}
public void AsyncSendNudge()
{
if ((this.Status == DialogStatus.Invited) && (this.ContentType == MessageContentType.HtmlFragment))
{
this.AsyncSendUserState("nudge");
this.AddChatFriends();
}
}
protected void AsyncSendResponse(SipRequest req)
{
SipResponse msg = base.CreateSipResponse(req);
base.SendSipMessage(msg);
}
private void AsyncSendResponse(int statusCode, string reasonPhrase, SipRequest req)
{
SipResponse msg = new SipResponse(statusCode, reasonPhrase, req);
msg.Message.AddHeader(new SipcFromHeader(base.Owner.Uri.Raw));
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
base.SendSipMessage(msg);
}
public Message AsyncSendSms(string content, AsyncBizOperation op)
{
return this.AsyncSendSms(content, true, op);
}
public Message AsyncSendSms(string content, bool saveMessage, AsyncBizOperation op)
{
Message message = new SMSMessage(this, content, this.MyDisplayName, base.Owner.Uri.Raw, false);
content = Imps.Utils.TagParser.TagParser.Create(content, false).Text;
SMSManager.AsyncSendSMS(base.Owner, this.To, content, op);
return message;
}
public void AsyncSendUserState(string state)
{
if (!string.IsNullOrEmpty(state))
{
SipRequest req = this.InnerCreateSipRequest("IN", this.CallId, this.NextCSeq);
req.Message.AddHeader(new SipcToHeader(this.To));
StringWriter tw = new StringWriter();
XmlHelper.CreateXmlWriterForSipMessage(tw, state, delegate (XmlWriter writer, object context) {
writer.WriteElementString("state", context as string);
}, "is-composing");
req.Message.Body = tw.ToString();
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
base.SendSipMessage(req);
}
}
private void AsyncUpgradeConversation(List<Imps.Client.Core.Contact> contacts)
{
if (contacts.get_Count() != 0)
{
if (!this.IsBeInvite)
{
if ((this.Participants.Count > 0) && !contacts.Contains(this.Participants[0].Contact))
{
contacts.Add(this.Participants[0].Contact);
}
this.CurrentConversation.AsyncCreateTemporaryGroup(contacts);
}
else
{
this.AsyncReferUpgradeConversation(contacts);
}
}
}
protected virtual bool CanReceiveContactMessage(Imps.Client.Core.Contact contact)
{
if ((this.Participants.Count <= 1) && contact.IsBlocked)
{
return false;
}
return true;
}
public void Close()
{
this.Close(true);
}
internal virtual void Close(bool bye)
{
try
{
if (bye && (this._waitingMessageResponseCount > 0))
{
this._waitingClose = true;
}
else
{
lock (this)
{
if (this._isClosed)
{
return;
}
this._isClosed = true;
}
if (bye || (base.Owner.Status != UserAccountStatus.Logon))
{
this.ShareContents.Clear();
}
if (bye)
{
if (this.Status == DialogStatus.Invited)
{
Thread.Sleep(100);
this.AsyncSendBye();
}
if (this.Status == DialogStatus.Inviting)
{
this.AsyncSendCancel();
}
}
base.Owner.SipRequestReceived -= new EventHandler<SipRequestReceivedEventArgs>(this, (IntPtr) this.Owner_SipRequestReceived);
base.Owner.SipNotifyReceived -= new EventHandler<SipRequestReceivedEventArgs>(this, (IntPtr) this.Owner_SipNotifyReceived);
this.RaiseClosed(EventArgs.Empty);
this.CurrentConversation.Dialogs.Remove(this);
if ((this.CurrentConversation.Dialogs.Count == 0) || this.IsMulitiConversation)
{
this.CurrentConversation.Close();
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
protected virtual void DoAddChatFriend(Imps.Client.Core.Contact contact)
{
if (contact is Stranger)
{
base.Owner.ContactList.AsyncAddChatFriend(contact.Uri, this.BizOperation);
}
}
protected virtual void DoAutoReplay(SipRequest req)
{
bool flag = false;
if ((req.Message.Event != null) && (req.Message.Event.Value == "auto-reply"))
{
flag = true;
}
if (((base.Owner.Presence.MainPresence == MainPresence.Away) && (base.Owner.Configuration.UserSetting.ConversationSetting.AutoReplyEnabled != null)) && !flag)
{
string[] autoReplies = base.Owner.Configuration.UserSetting.AutoReplies;
int index = (int) base.Owner.Configuration.UserSetting.ConversationSetting.AutoReplyIndex;
if (autoReplies.Length > index)
{
Message msg = this.GetSendMessage(autoReplies[index]);
this.AsyncSendMessage(msg, true);
this.RaiseMessageReceived(new MessageEventArgs(msg));
}
}
}
protected virtual void DoCCToSms(SipRequest req, Imps.Client.Core.Contact contact)
{
try
{
if ((!this.IsMulitiConversation && (base.Owner.Presence.MainPresence == MainPresence.Away)) && (!base.Owner.Presence.IsOffline && base.Owner.Configuration.UserSetting.ConversationSetting.MessageToSMS.Value))
{
string source = req.Message.Body;
if (req.Message.ContentType.Value == "text/html-fragment")
{
source = Imps.Utils.TagParser.TagParser.Create(source, true).Text;
}
this.AsyncCCToSms(contact, source);
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void DoDialogStatusChanged(DialogStatus old)
{
if ((old == DialogStatus.Inviting) && (this._temporaryMessages != null))
{
List<Message>.Enumerator enumerator = this._temporaryMessages.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Message msg = enumerator.get_Current();
this.InnerSendIm(msg);
}
}
finally
{
enumerator.Dispose();
}
this._temporaryMessages.Clear();
}
}
protected virtual void DoFindConversationWindow(Imps.Client.Core.Contact contact, Message msg)
{
if (!this.CurrentConversation.OwnerFormCreated)
{
base.Owner.ConversationManager.RaiseFindConversationForm(this._conv, contact, Imps.Utils.TagParser.TagParser.Create(string.Format("{0}:\r\n{1}", "{0}", msg.Content), false).Text);
if (this._waitingClose)
{
this._waitingClose = false;
}
}
}
private void DoReceiveActionInfo(XmlDocument doc, Imps.Client.Core.Contact contact)
{
string text;
if (((text = doc.DocumentElement.Attributes["type"].Value) != null) && (text == "share-content"))
{
this.DoReceiveShareContent(doc, contact);
}
}
private void DoReceiveBeNotify(SipRequest req)
{
string text;
if (((req.Message.Event != null) && ((text = req.Message.Event.Value.ToLower()) != null)) && (text == "group"))
{
this.DoReceiveTempGroupNotify(req);
}
}
protected virtual void DoReceiveBye(SipRequest req)
{
this.AsyncSendResponse(req);
this._closeByBye = true;
this.Close(false);
}
private void DoReceiveCancel(SipRequest req)
{
this.AsyncSendResponse(req);
if (this.Status != DialogStatus.Invited)
{
this.Close(false);
}
}
private void DoReceiveInfo(SipRequest req)
{
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(req.Message.Body);
string uri = this.To;
if (this.IsMulitiConversation)
{
if (req.Message.SourceHeader == null)
{
throw new ArgumentNullException("Multi. Conversation Need SourceHeader");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -