protected virtual void HandleXfr(NotificationConnection c, Command cmd) { // >>> XFR TrID SB // <<< XFR TrID SB Address SP AuthChallengeInfo if (cmd.Params[0] != "SB") // only XFRs to Switchboard servers are supported, besides what else is there to XFR to? { Command errResponse = new Command(Error.SyntaxError, cmd.TrId); Server.Send(c, errResponse); return; } // provision the new session SwitchboardServer sb = SwitchboardServer.Instance; SwitchboardSession session = sb.CreateSession(c.User); SwitchboardInvitation invite = session.CreateInvitation(c.User); invite.Protocol = c.Protocol.Name; Command xfrResponse = new Command(Verb.Xfr, cmd.TrId, "SB", sb.GetEndPointForClient(c.Socket.LocalEndPoint).ToString(), "CKI", invite.Key); Server.Send(c, xfrResponse); }
protected virtual void HandleCal(SwitchboardConnection c, Command cmd) { // >>> CAL TrID UserHandle // <<< CAL TrID Status SessionID String recipientHandle = cmd.Params[0]; User recipient = User.GetUser(recipientHandle); if (recipient.NotificationServer == null || (recipient.Status & Status.Nln) != Status.Nln) { // the user is not online (or is hidden) Command responseErr = new Command(Error.SwitchboardFailed, cmd.TrId); // I guess? Server.Send(c, responseErr); return; } // if the invited user is allowed to contact the calling user (or vice-versa) then that user's notification server sends a RNG // otherwise, SB returns an error // TODO: Check permissions first User caller = c.User; SwitchboardSession session = c.Session; SwitchboardInvitation invite = session.CreateInvitation(recipient); recipient.NotificationServer.ASNotifyRng(caller, recipient, invite); Command responseOk = new Command(Verb.Cal, cmd.TrId, "RINGING", session.Id.ToStringInvariant()); Server.Send(c, responseOk); }