/// <inheritdoc/> public override async Task RunAsync(CancellationToken stoppingToken) { StoppingToken = stoppingToken; // TODO: fallback on bot gateway data? var uri = new Uri("wss://gateway.discord.gg/"); await GatewayClient.RunAsync(uri, stoppingToken).ConfigureAwait(false); }
public override String CaptureOrder(Order o) { String result = AppLogic.ro_OK; o.CaptureTXCommand = ""; o.CaptureTXResult = ""; String TransID = o.AuthorizationPNREF; if (TransID.Length == 0 || TransID == "0") { result = "Invalid or Empty Transaction ID"; } else { try { GatewayClient client = SecureNetController.GetGatewayClient(); TRANSACTION oT = SecureNetController.GetTransactionWithDefaults(); oT.CODE = SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.PRIOR_AUTH_CAPTURE); oT.AMOUNT = o.OrderBalance; oT.METHOD = SecureNetMethod.CC.ToString(); oT.REF_TRANSID = TransID; oT.ORDERID = o.OrderNumber.ToString(); String cardnumber = DB.GetSqlS("select Last4 S from Orders with (NOLOCK) where OrderNumber=" + o.OrderNumber.ToString()); if (!String.IsNullOrEmpty(cardnumber)) { oT.CARD = new CARD(); oT.CARD.CARDNUMBER = cardnumber; oT.CARD.EXPDATE = o.CardExpirationMonth.PadLeft(2, '0') + o.CardExpirationYear.ToString().Substring(2, 2); //MMYY } oT.INVOICENUM = o.OrderNumber.ToString(); oT.INVOICEDESC = AppLogic.AppConfig("StoreName"); GATEWAYRESPONSE oTr = client.ProcessTransaction(oT); if (oTr.TRANSACTIONRESPONSE.RESPONSE_CODE == "1") // 1=Approved, 2=Declined, 3=Error { result = AppLogic.ro_OK; } else { result = "Error: [" + oTr.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oTr.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT; } o.CaptureTXCommand = this.GetXMLSerializedObject(oT); o.CaptureTXResult = this.GetXMLSerializedObject(oTr); } catch { result = "NO RESPONSE FROM GATEWAY!"; } } return(result); }
public UserController(IBackgroundJobClient backgroundJob, GatewayClient gatewayClient, ILogger <UserController> logger) { this.backgroundJob = backgroundJob; this.gatewayClient = gatewayClient; this.logger = logger; }
/// <summary> /// Forwards raw packets straight to the associated client. /// </summary> /// <param name="buffer"></param> private void ForwardToClient(byte[] buffer) { GatewayClient client = null; try { uint session = BitConverter.ToUInt32(buffer, 2); if (GatewayPool.Instance.lookup.TryGetValue(session, out client)) { client.Send(buffer); } else { Console.WriteLine("Unable to find client"); } } catch (ObjectDisposedException) { if (client != null) { client.world = null; client.Close(); } } catch (Exception) { if (client != null) { client.world = null; client.Close(); } } }
private static void ChooseMethod(GatewayClient gatewayClient, bool error = false) { Console.Clear(); Console.WriteLine("Press number representing action:"); foreach (var keyValue in MethodList) { Console.WriteLine($"{keyValue.Key}. {keyValue.Value}"); } if (error) { Console.WriteLine("\nYou must enter id of method in list!"); } Console.WriteLine(); Console.Write("Select method: "); var result = CheckInput(Console.ReadLine()); if (result == null) { ChooseMethod(gatewayClient, true); } Console.WriteLine($"\nSelected method: {result} - {MethodList[result.Value]}"); Start(gatewayClient, result.Value); Console.ReadLine(); ChooseMethod(gatewayClient); }
protected override void ProcessRecord() { base.ProcessRecord(); try { client?.Dispose(); int timeout = GetPreferredTimeout(); WriteDebug($"Cmdlet Timeout : {timeout} milliseconds."); client = new GatewayClient(AuthProvider, new Oci.Common.ClientConfiguration { RetryConfiguration = retryConfig, TimeoutMillis = timeout, ClientUserAgent = PSUserAgent }); string region = GetPreferredRegion(); if (region != null) { WriteDebug("Choosing Region:" + region); client.SetRegion(region); } if (Endpoint != null) { WriteDebug("Choosing Endpoint:" + Endpoint); client.SetEndpoint(Endpoint); } } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public bool Request(GatewayClient client) { try { if (Sessions.Count == 0) { this.PendingSessionQueuee.Enqueue(client); LoginClient clienta; if (NetworkManager.TryGetLoginClient(out clienta)) { clienta.RequestSessionId(); return(true); } else { return(false); } } else { uint session = Sessions.Dequeue(); client.SetSessionId(session); return(true); } } catch (Exception ex) { throw new SessionRequestException("Requesting the session id has failed - unknown exception occured", ex); } }
/// <summary> /// Creates a Bot client that connects itself to the api gateway /// </summary> /// <returns></returns> private async Task <GatewayClient> CreateExternalClient() { var config = GetConfig(); var info = new GatewayInformation(config); var clientInfo = new ClientInformation() { Credentials = new ClientCredentials() { ClientId = info.ExternalClientInfo.ClientId, ClientSecret = info.ExternalClientInfo.ClientSecret }, TargetApiName = info.GatewayApiName, TargetBaseUrl = info.GatewayApiBaseUrl, AuthServerLocation = info.AuthServerUrl }; var clientInfoOptions = new OptionsWrapper <ClientInformation>(clientInfo); var client = new GatewayClient(clientInfoOptions, new MockLoggerFactory <object>()); var tokenResponse = await GetAccessTokenFromAuthServer(clientInfo); client.SetBearerToken(tokenResponse.AccessToken); return(client); }
public FailJobCommand(GatewayClient client, long jobKey) { gatewayClient = client; request = new FailJobRequest { JobKey = jobKey }; }
public CompleteJobCommand(GatewayClient client, long jobKey) { gatewayClient = client; request = new CompleteJobRequest { JobKey = jobKey }; }
public ThrowErrorCommand(GatewayClient client, long jobKey) { gatewayClient = client; request = new ThrowErrorRequest { JobKey = jobKey }; }
public ThrowErrorCommand(GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy, long jobKey) { gatewayClient = client; this.asyncRetryStrategy = asyncRetryStrategy; request = new ThrowErrorRequest { JobKey = jobKey }; }
static void Main(string[] args) { var gatewayClient = new GatewayClient( merchantId: Constants.MerchantId, privateKeyFilePath: Constants.PrivateKeyFilePath ); ChooseMethod(gatewayClient); }
public Mayushii() { string mayushii = new StreamReader(File.OpenRead("./Mayushii.id")).ReadToEnd(); client = new GatewayClient(mayushii); client.Initialize(); client.OnConnected += client.Login; client.OnReceiveMessage += Client_OnReceiveMessage; }
public CompleteJobCommand(GatewayClient client, IAsyncRetryStrategy asyncRetryStrategy, long jobKey) { gatewayClient = client; request = new CompleteJobRequest { JobKey = jobKey }; this.asyncRetryStrategy = asyncRetryStrategy; }
public ConsentNotificationController( IConsentRepository consentRepository, IBackgroundJobClient backgroundJob, GatewayClient gatewayClient) { this.consentRepository = consentRepository; this.backgroundJob = backgroundJob; this.gatewayClient = gatewayClient; }
public CareContextDiscoveryController(PatientDiscovery patientDiscovery, GatewayClient gatewayClient, IBackgroundJobClient backgroundJob, ILogger <CareContextDiscoveryController> logger) { this.patientDiscovery = patientDiscovery; this.gatewayClient = gatewayClient; this.backgroundJob = backgroundJob; this.logger = logger; }
private static void InitializeGatewayContainers() { BatchTestBase.GatewayClient = TestCommon.CreateCosmosClient(useGateway: true); BatchTestBase.GatewayDatabase = GatewayClient.GetDatabase(BatchTestBase.Database.Id); BatchTestBase.GatewayLowThroughputJsonContainer = BatchTestBase.GatewayDatabase.GetContainer(BatchTestBase.LowThroughputJsonContainer.Id); BatchTestBase.GatewayJsonContainer = BatchTestBase.GatewayDatabase.GetContainer(BatchTestBase.JsonContainer.Id); BatchTestBase.GatewaySchematizedContainer = BatchTestBase.GatewayDatabase.GetContainer(BatchTestBase.SchematizedContainer.Id); }
private void ShouldReturnDataToGateway() { var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); var httpClient = new HttpClient(handlerMock.Object); var gatewayConfiguration = new GatewayConfiguration { Url = "http://someUrl" }; var authenticationUri = new Uri($"{gatewayConfiguration.Url}/{PATH_SESSIONS}"); var expectedUri = new Uri($"{gatewayConfiguration.Url}{PATH_ON_DISCOVER}"); var patientEnquiryRepresentation = new PatientEnquiryRepresentation( "123", "Jack", new List <CareContextRepresentation>(), new List <string>()); var gatewayDiscoveryRepresentation = new GatewayDiscoveryRepresentation( patientEnquiryRepresentation, Guid.NewGuid(), DateTime.Now, "transactionId", null, new Resp("requestId")); var gatewayClient = new GatewayClient(httpClient, gatewayConfiguration); var definition = new { accessToken = "Whatever", tokenType = "Bearer" }; var result = JsonConvert.SerializeObject(definition); var correlationId = Uuid.Generate().ToString(); handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsInOrder(() => Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(result) }), () => Task.FromResult(new HttpResponseMessage { StatusCode = HttpStatusCode.OK })); gatewayClient.SendDataToGateway(PATH_ON_DISCOVER, gatewayDiscoveryRepresentation, "ncg", correlationId); handlerMock.Protected().Verify( "SendAsync", Times.Exactly(1), ItExpr.Is <HttpRequestMessage>(message => message.Method == HttpMethod.Post && message.RequestUri == expectedUri), ItExpr.IsAny <CancellationToken>()); handlerMock.Protected().Verify( "SendAsync", Times.Exactly(1), ItExpr.Is <HttpRequestMessage>(message => message.Method == HttpMethod.Post && message.RequestUri == authenticationUri), ItExpr.IsAny <CancellationToken>()); }
public override Task OnLoad() { _instrument = new InstrumentModel { Name = _asset, TimeFrame = _span }; var account = new AccountModel { Name = _account, Balance = 50000, InitialBalance = 50000, Instruments = new NameCollection <string, IInstrumentModel> { [_asset] = _instrument } }; var gateway = new GatewayClient { Speed = 100, Name = _account, Account = account, Evaluate = Parse, Source = ConfigurationManager.AppSettings["DataLocation"].ToString() }; _rsiIndicator = new RelativeStrengthIndicator { Interval = 10, Name = "RSI Indicator : " + _asset }; _atrIndicator = new AverageTrueRangeIndicator { Interval = 10, Name = "ATR Indicator : " + _asset }; _bidIndicator = new MovingAverageIndicator { Interval = 0, Mode = MovingAverageEnum.Bid, Name = "BID Indicator : " + _asset }; _askIndicator = new MovingAverageIndicator { Interval = 0, Mode = MovingAverageEnum.Ask, Name = "ASK Indicator : " + _asset }; _performanceIndicator = new PerformanceIndicator { Name = "Balance" }; _disposables.Add(gateway .Account .Instruments .Values .Select(o => o.PointGroups.ItemStream) .Merge() .Subscribe(OnData)); CreateCharts(); CreateGateways(gateway); return(Task.FromResult(0)); }
public LinkController( IDiscoveryRequestRepository discoveryRequestRepository, IBackgroundJobClient backgroundJob, LinkPatient linkPatient, GatewayClient gatewayClient) { this.discoveryRequestRepository = discoveryRequestRepository; this.backgroundJob = backgroundJob; this.linkPatient = linkPatient; this.gatewayClient = gatewayClient; }
private void Remove_Clicked(object sender, RoutedEventArgs e) { if (GatewayUserModel.Count == 0) { return; } GatewayClient.RemoveUser(GatewayPivot.SelectedIndex); LoadUsers(); }
/* Gateway Listener, new client connection accepted event handler */ private void GatewayListener_NewGatewayConnected(GatewayClient client) { client.ConnectionClosed += GatewayClientConnectionClosed; /* We are locking the adding operation because in the case * of any connection closed, the list will be modified */ lock (gateways) { gateways.Add(client); } }
public int HandlePacket(ClientBase client, GamePacket packet) { GatewayClient gc = client as GatewayClient; if (GatewayGlobal.Players.Contains(gc.PlayerID) && gc.PlayerID == packet.PlayerID) { gc.LogicServer.SendTCP(packet); } return(0); }
public static void Main(string[] args) { Console.WriteLine("============================ IBM WatsonIoTP Sample ============================"); Console.WriteLine("Example for gateway"); string orgId = ""; string gatewayDeviceType = ""; string gatewayDeviceID = ""; string authMethod = "token"; string authToken = ""; Console.Write("Enter your org id :"); orgId = Console.ReadLine(); Console.Write("Enter your gateway type :"); gatewayDeviceType = Console.ReadLine(); Console.Write("Enter your gateway id :"); gatewayDeviceID = Console.ReadLine(); Console.Write("Enter your auth token :"); authToken = Console.ReadLine(); GatewayClient gw = new GatewayClient(orgId, gatewayDeviceType, gatewayDeviceID, authMethod, authToken); gw.commandCallback += processCommand; gw.errorCallback += processError; gw.connect(); Console.WriteLine("Gateway connected"); Console.WriteLine("publishing gateway events.."); gw.publishGatewayEvent("test", "{\"temp\":25}"); gw.publishGatewayEvent("test", "{\"temp\":22}", 2); string deviceType = ""; string deviceId = ""; string deviceEvent = "testdevevt"; string deviceEventValue = "{\"temp\":100}"; Console.WriteLine("please enter connected device details:"); Console.Write("Enter your device type :"); deviceType = Console.ReadLine(); Console.Write("Enter your device id :"); deviceId = Console.ReadLine(); Console.WriteLine("publishing device events.."); gw.publishDeviceEvent(deviceType, deviceId, deviceEvent, deviceEventValue); gw.subscribeToDeviceCommands(deviceType, deviceId); Console.WriteLine("Press any key to exit . . . "); Console.ReadKey(); gw.disconnect(); }
private void Edit_Clicked(object sender, RoutedEventArgs e) { if (GatewayUserModel.Count == 0) { return; } int i = GatewayPivot.SelectedIndex; GatewayClient.EditUser(i, GatewayUserModel[i].Username, GatewayUserModel[i].Password); LoadUsers(); }
private void Default_Clicked(object sender, RoutedEventArgs e) { if (GatewayUserModel.Count == 0) { return; } int i = GatewayPivot.SelectedIndex; GatewayClient.SetDefaultUser(i); LoadUsers(); }
public override Task OnLoad() { var span = TimeSpan.FromMinutes(1); var instrumentX = new InstrumentModel { Name = _assetX, TimeFrame = span }; var instrumentY = new InstrumentModel { Name = _assetY, TimeFrame = span }; var account = new AccountModel { Balance = 50000, Name = _account, Instruments = new NameCollection <string, IInstrumentModel> { [_assetX] = instrumentX, [_assetY] = instrumentY } }; var gateway = new GatewayClient { Name = _account, Account = account, Evaluate = Parse, Source = ConfigurationManager.AppSettings["DataLocation"].ToString() }; _performanceIndicator = new PerformanceIndicator { Name = "Balance" }; _scaleIndicatorX = new ScaleIndicator { Max = 1, Min = -1, Interval = 1, Name = "Indicators : " + _assetX }; _scaleIndicatorY = new ScaleIndicator { Max = 1, Min = -1, Interval = 1, Name = "Indicators : " + _assetY }; _disposables.Add(gateway .Account .Instruments .Values .Select(o => o.PointGroups.ItemStream) .Merge() .Subscribe(OnData)); CreateCharts(instrumentX, instrumentY); CreateGateways(gateway); return(Task.FromResult(0)); }
public int HandlePacket(ServerConnector connector, GamePacket packet) { int clientID = packet.ReadInt(); GatewayClient client = GatewayGlobal.Clients[clientID]; if (client != null) { client.SendTcp(packet); } return(0); }
public void Setup() { mockTransport = new Moq.Mock <ITransport>(); client = new GatewayClient(mockTransport.Object); last_request_xml = new System.Xml.Linq.XDocument(); mockTransport.Setup((t) => t.Send(It.IsAny <System.Xml.Linq.XDocument>())).Returns <System.Xml.Linq.XDocument>((xml) => { last_request_xml = xml; return(new TransportResult() { Content = new System.Xml.Linq.XDocument() }); }); }
public void Logout(GatewayClient client) { Packets.Login.Send.Logout p = new SagaGateway.Packets.Login.Send.Logout(); p.SetSessionID(client.SessionID); this.netIO.SendPacket(p, client.SessionID); }
/// <summary> /// Connects new clients /// </summary> public override void NetworkLoop(int maxNewConnections) { for (int i = 0; listener.Pending() && i < maxNewConnections; i++) { Socket sock = listener.AcceptSocket(); string ip = sock.RemoteEndPoint.ToString().Substring(0, sock.RemoteEndPoint.ToString().IndexOf(':')); if (Gateway.lcfg.Banned_IP.Contains(ip)) { Logger.ShowWarning("Conncetion from banned IP:" + ip + " rejected!"); sock.Close(); } else { Logger.ShowInfo("New client from: " + sock.RemoteEndPoint.ToString(), null); GatewayClient newClient = new GatewayClient(sock, this.commandTable); } } }
public void RequestNewSession(GatewayClient client) { Packets.Login.Send.NewClient p = new SagaGateway.Packets.Login.Send.NewClient(); this.waitingQueue.Add(client); this.netIO.SendPacket(p, this.SessionID); }