private byte[] CreateCallContent(SignalServiceCallMessage callMessage) { Content content = new Content(); CallMessage pushCallMessage = new CallMessage(); if (callMessage.OfferMessage != null) { pushCallMessage.Offer = new CallMessage.Types.Offer() { Id = callMessage.OfferMessage.Id, Description = callMessage.OfferMessage.Description }; } else if (callMessage.AnswerMessage != null) { pushCallMessage.Answer = new CallMessage.Types.Answer() { Id = callMessage.AnswerMessage.Id, Description = callMessage.AnswerMessage.Description }; } else if (callMessage.IceUpdateMessages != null) { foreach (IceUpdateMessage u in callMessage.IceUpdateMessages) { pushCallMessage.IceUpdate.Add(new CallMessage.Types.IceUpdate() { Id = u.Id, Sdp = u.Sdp, SdpMid = u.SdpMid, SdpMLineIndex = u.SdpMLineIndex }); } } else if (callMessage.HangupMessage != null) { pushCallMessage.Hangup = new CallMessage.Types.Hangup() { Id = callMessage.HangupMessage.Id }; } else if (callMessage.BusyMessage != null) { pushCallMessage.Busy = new CallMessage.Types.Busy() { Id = callMessage.BusyMessage.Id }; } content.CallMessage = pushCallMessage; return(content.ToByteArray()); }
private SignalServiceContent(SignalServiceCallMessage callMessage, SignalServiceAddress sender, int senderDevice, long timestamp, bool needsReceipt, SignalServiceContentProto serializedState) { Sender = sender; SenderDevice = senderDevice; Timestamp = timestamp; NeedsReceipt = needsReceipt; this.serializedState = serializedState; Message = null; SynchronizeMessage = null; CallingMessage = callMessage; ReadMessage = null; TypingMessage = null; }
/// <summary> /// Send a call setup message to a single recipient /// </summary> /// <param name="token">The cancellation token</param> /// <param name="recipient">The message's destination</param> /// <param name="message">The call message</param> public async Task SendCallMessage(CancellationToken token, SignalServiceAddress recipient, SignalServiceCallMessage message) { byte[] content = CreateCallContent(message); await SendMessage(token, recipient, Util.CurrentTimeMillis(), content, true); }
/// <summary> /// Send a call setup message to a single recipient /// </summary> /// <param name="token">The cancellation token</param> /// <param name="recipient">The message's destination</param> /// <param name="unidentifiedAccess"></param> /// <param name="message">The call message</param> public async Task SendCallMessage(CancellationToken token, SignalServiceAddress recipient, UnidentifiedAccessPair?unidentifiedAccess, SignalServiceCallMessage message) { byte[] content = CreateCallContent(message); await SendMessage(token, recipient, unidentifiedAccess?.TargetUnidentifiedAccess, Util.CurrentTimeMillis(), content); }
private static SignalServiceCallMessage CreateCallingMessage(CallingMessage content) { if (content.Offer != null) { return(new SignalServiceCallMessage() { OfferMessage = new OfferMessage() { Id = content.Offer.CallId, Opaque = content.Offer.Opaque.ToByteArray() } }); } else if (content.Answer != null) { return(new SignalServiceCallMessage() { AnswerMessage = new AnswerMessage() { Id = content.Answer.CallId, Opaque = content.Answer.Opaque.ToByteArray() } }); } else if (content.IceCandidates.Count > 0) { var m = new SignalServiceCallMessage(); var l = new List <IceUpdateMessage>(); foreach (var u in content.IceCandidates) { l.Add(new IceUpdateMessage() { CallId = u.CallId, Opaque = u.Opaque.ToByteArray() }); } m.IceUpdateMessages = l; return(m); } else if (content.Hangup != null) { return(new SignalServiceCallMessage() { HangupMessage = new HangupMessage() { Id = content.Hangup.CallId, } }); } else if (content.Busy != null) { return(new SignalServiceCallMessage() { BusyMessage = new BusyMessage() { Id = content.Busy.CallId } }); } return(new SignalServiceCallMessage()); }
private SignalServiceCallMessage createCallMessage(CallMessage content) { if (content.OfferOneofCase == CallMessage.OfferOneofOneofCase.Offer) { return(new SignalServiceCallMessage() { OfferMessage = new OfferMessage() { Id = content.Offer.Id, Description = content.Offer.Description } }); } else if (content.AnswerOneofCase == CallMessage.AnswerOneofOneofCase.Answer) { return(new SignalServiceCallMessage() { AnswerMessage = new AnswerMessage() { Id = content.Answer.Id, Description = content.Answer.Description } }); } else if (content.IceUpdate.Count > 0) { var m = new SignalServiceCallMessage(); var l = new List <IceUpdateMessage>(); foreach (var u in content.IceUpdate) { l.Add(new IceUpdateMessage() { Id = u.Id, SdpMid = u.SdpMid, SdpMLineIndex = u.SdpMLineIndex, Sdp = u.Sdp }); } m.IceUpdateMessages = l; return(m); } else if (content.HangupOneofCase == CallMessage.HangupOneofOneofCase.Hangup) { return(new SignalServiceCallMessage() { HangupMessage = new HangupMessage() { Id = content.Hangup.Id, } }); } else if (content.BusyOneofCase == CallMessage.BusyOneofOneofCase.Busy) { return(new SignalServiceCallMessage() { BusyMessage = new BusyMessage() { Id = content.Busy.Id } }); } return(new SignalServiceCallMessage()); }
public void sendCallMessage(SignalServiceAddress recipient, SignalServiceCallMessage message) { byte[] content = createCallContent(message); sendMessage(recipient, Util.CurrentTimeMillis(), content, false, true); }