public void HandleConnectMsg(TextCommand cmd, ProtocolContext ctx) { var clientInfo = Util.GetClientInfo(cmd.device_id); if (clientInfo == null) { if (Util.RejectUnpairedDevices) { ctx.SetState(new UnconnectedState()); log4net.LogManager.GetLogger("pairing").Debug("send denied because reject-all is enabled, state = unconnected"); ctx.Send(new { action = "denied", reason = "Not allowed" }); ctx.Stop(WebSocketSharp.Frame.CloseStatusCode.POLICY_VIOLATION, "Not allowed"); } else { log4net.LogManager.GetLogger("pairing").Debug("send wait-for-pair, state = " + ctx.GetState().ToString()); ctx.Send(new { action = "wait-for-pair" }); ctx.SetState(new WaitForApproveState()); ctx.raiseOnPairingRequired(); } } else { ctx.device_folder_name = clientInfo.folder_name; ReplyAcceptMsgToDevice(ctx, clientInfo); } }
public override void handleDisapprove(ProtocolContext ctx) { var response = new { action = "denied", reason = "user rejected" }; log4net.LogManager.GetLogger("pairing").Debug("send denied"); ctx.Send(response); ctx.Stop(WebSocketSharp.Frame.CloseStatusCode.POLICY_VIOLATION, "User rejected"); ctx.SetState(new UnconnectedState()); }