/// <summary> /// 呼叫 /// </summary> /// <param name="callID">呼叫ID</param> /// <param name="type">呼叫类型 1:音频 2:视频</param> /// <param name="from">呼叫者 ID</param> /// <param name="to">被呼叫者ID </param> public void Call(string callID, ChatType type, int from, int to) { if (CallID == "") { CallID = callID; ProtocolDataModel pd = new ProtocolDataModel(); pd.Type = ProtocolType.TYPE_IM; pd.Request = IMProtocol.IM_CALL_CRE; IMInfo info = new IMInfo(); info.UserName = UserName; info.UserID = UserID; info.CallID = callID; info.CallType = (int)type; ChatDataHandler.Instance.ChatType = type; info.PeerID = to; ChatPeerID = to; using (MemoryStream stream = new MemoryStream()) { info.WriteTo(stream); pd.Message = stream.ToArray(); } NetWorkManager.Instance.Send(pd); } }
/// <summary> /// 挂断 /// </summary> public void Hang() { if (CallID != "") { CallID = ""; ProtocolDataModel pd = new ProtocolDataModel(); pd.Type = ProtocolType.TYPE_IM; pd.Request = IMProtocol.IM_HANG_CRES; IMInfo info = new IMInfo(); info.PeerID = ChatPeerID; using (MemoryStream stream = new MemoryStream()) { info.WriteTo(stream); pd.Message = stream.ToArray(); } NetWorkManager.Instance.Send(pd); //结束udp传输 ChatDataHandler.Instance.StopChat(); } }
/// <summary> /// 接听 /// </summary> public void Accept() { ProtocolDataModel pd = new ProtocolDataModel(); pd.Type = ProtocolType.TYPE_IM; pd.Request = IMProtocol.IM_ACCEPT_CRES; IMInfo info = new IMInfo(); info.UserName = UserName; info.UserID = UserID; info.PeerID = ChatPeerID; //info.CallType = type; using (MemoryStream stream = new MemoryStream()) { info.WriteTo(stream); pd.Message = stream.ToArray(); } NetWorkManager.Instance.Send(pd); //开始udp传输 ChatDataHandler.Instance.StartChat(); }