public ItemDetails() {//string aspKey, string customerKey, string password, string serviceUrl, string directory, string cookie InitializeComponent(); ctx = new WSContext(Properties.Settings.Default.AspKey, Properties.Settings.Default.CustomerKey, Properties.Settings.Default.Password, Properties.Settings.Default.ServiceEndpointAddress, Properties.Settings.Default.StorageDirectory, Properties.Settings.Default.Cookie); client = new WSClient(ctx); getARTerms(); getTrademarkList(); getItemTypes(); }
static void Init1() { ConsoleHelper.WriteLine("WSServer 正在初始化....", ConsoleColor.Green); _server = new WSServer(); _server.OnMessage += Server_OnMessage; _server.OnDisconnected += _server_OnDisconnected; _server.Start(); ConsoleHelper.WriteLine("WSServer 就绪,回车启动客户端", ConsoleColor.Green); ConsoleHelper.ReadLine(); WSClient client = new WSClient(); client.OnPong += Client_OnPong; client.OnMessage += Client_OnMessage; client.OnError += Client_OnError; client.OnDisconnected += Client_OnDisconnected; ConsoleHelper.WriteLine("WSClient 正在连接到服务器...", ConsoleColor.DarkGray); var connected = client.Connect(); if (connected) { ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray); ConsoleHelper.ReadLine(); //client.Close(); //ConsoleHelper.ReadLine(); ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray); client.Send($"hello world!{DateTime.Now.ToString("HH:mm:ss.fff")}"); ConsoleHelper.ReadLine(); ConsoleHelper.WriteLine("WSClient 正在ping服务器...", ConsoleColor.DarkGray); client.Ping(); ConsoleHelper.ReadLine(); ConsoleHelper.WriteLine("WSClient 正在断开连接..."); client.Close(); ConsoleHelper.ReadLine(); } else { ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray); } }
public MainWindow() { InitializeComponent(); this.SetOnScreen(); client = new WSClient(); windowOpen = true; double screenHeight = SystemParameters.PrimaryScreenHeight; double screenWidth = SystemParameters.PrimaryScreenWidth; client.SetScreenResolution((int)screenWidth, (int)screenHeight); client.Error += new WSClient.ErrorEventHandler(OnError); client.ConnectionChange += new WSClient.ConnectionChangedHandler(OnConnectionChanged); }
public CreateSO() { SoLines = new List <XMLModel.Item>(); InitializeComponent(); WindowHeight = 800; ctx = new WSContext(Properties.Settings.Default.AspKey, Properties.Settings.Default.CustomerKey, Properties.Settings.Default.Password, Properties.Settings.Default.ServiceEndpointAddress, Properties.Settings.Default.StorageDirectory, Properties.Settings.Default.Cookie); client = new WSClient(ctx); getARTerms(); populateFOBKey(); populateCities(); SOLinesInput.ItemsSource = SoLines; }
private static void Client_OnConnected1(WSClient client) { ConsoleHelper.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " 当前客户端已连上"); FunHelper.WhileAsync(() => { //client.SendAsync(longStr); client.SendAsync(new GFF.WS.Model.WSMessage() { ID = Guid.NewGuid().ToString("N"), Content = longStr, Sender = "CS", time = DateTime.Now.Ticks.ToString() }); }, 1000); }
static void Init4() { ConsoleHelper.WriteLine("WSClient 正在连接到WorkMan服务器...", ConsoleColor.DarkGray); var url = "ws://123.207.136.134:9010/ajaxchattest"; WSClient client = new WSClient(url, SubProtocolType.Empty, "http://coolaf.com"); client.OnPong += Client_OnPong; client.OnMessage += Client_OnMessage; client.OnError += Client_OnError; client.OnDisconnected += Client_OnDisconnected; var connected = client.Connect(); if (connected) { ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray); ConsoleHelper.ReadLine(); client.Ping(); ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray); client.Send($"1111"); client.Send($"1111"); client.Send($"1111"); ConsoleHelper.WriteLine("WSClient 已发送消息", ConsoleColor.DarkGray); ConsoleHelper.WriteLine("回车WSClient 断开连接"); ConsoleHelper.ReadLine(); client.Close(); } else { ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray); } }
static void Init3() { ConsoleHelper.WriteLine("WSClient 正在连接到WorkMan服务器...", ConsoleColor.DarkGray); var url = "ws://120.79.233.58:7272"; WSClient client = new WSClient(url, SubProtocolType.Json); client.OnPong += Client_OnPong; client.OnMessage += Client_OnMessage; client.OnError += Client_OnError; client.OnDisconnected += Client_OnDisconnected; var connected = client.Connect(); if (connected) { ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray); ConsoleHelper.ReadLine(); client.Ping(); ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray); client.Send($"hello world!{DateTime.Now.ToString("HH:mm:ss.fff")}"); ConsoleHelper.WriteLine("WSClient 已发送消息", ConsoleColor.DarkGray); ConsoleHelper.ReadLine(); ConsoleHelper.WriteLine("回车WSClient 断开连接"); ConsoleHelper.ReadLine(); client.Close(); ConsoleHelper.ReadLine(); } else { ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray); } }
/// <summary> /// Synchro des clients /// </summary> private async void SyncClients() { DBClient db = new DBClient(); DBEstimation dbe = new DBEstimation(); List <Client> clientstest = db.GetAllByCommercial(Global.commercial.ID); List <Client> clients = db.getAllNoSynchroByCommercial(Global.commercial.ID); foreach (Client c in clients) { List <Estimation> estimations = dbe.GetNoSynchroByClient(c.ID); c.Estimations = new System.Collections.ObjectModel.ObservableCollection <Estimation>(estimations); } IsBusy = true; WSClient ws = new WSClient(); await ws.PostClients(Global.commercial.Token, clients, SyncCallback); IsBusy = false; }
private void Start() { // 縦画面にする Screen.orientation = ScreenOrientation.Portrait; _QR = QR.GetComponent <QRReader>(); ws = GameObject.Find("WSClient").GetComponent <WSClient>(); // バージョン情報の表示 LabelVersion.text = "Ver. " + Application.version; // UIパーツの取得 _LabelIPMode = IPModeView.transform.Find("Text").GetComponent <Text>(); _LabelPin = PinView.transform.Find("Text").GetComponent <Text>(); _LabelQR = QRView.transform.Find("Text").GetComponent <Text>(); _InputIP = IPModeView.transform.Find("InputField").GetComponent <InputField>(); _InputPin = PinView.transform.Find("InputField").GetComponent <InputField>(); }
public static void ClientInit(bool status = false) { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " 客户端测试"); WSClient client = new WSClient(); if (!status) { client.OnConnected += Client_OnConnected; } else { client.OnConnected += Client_OnConnected1; } client.OnReceived += Client_OnReceived; client.OnReceivedMessage += Client_OnReceivedMessage; client.ConnectAsync(url); }
private async Task OnReceive(WSClient client, string content, byte[] arg3) { if (content == null) { return; } if (!TryDeserialize(content.TrimEnd('\0'), out MessageObject obj)) { return; } var id = _clients[client]; switch (obj.EventType) { case "SEND": STextMessageObject message = ConvertToType <STextMessageObject>(obj.Value as JObject); foreach (var item in _clients) { await item.Key.SendMessageAsync(JsonConvert.SerializeObject(new MessageObject("MESSAGE", new TextMessageObject(message.Content, _clients[client])))); } break; case "VOICE_CONNECT": if (_voiceClients.Contains(client)) { return; } Random a = new Random(); uint b; while (true) { if (_voiceClients.Contains(b = (uint)a.Next(0, int.MaxValue))) { continue; } _voiceClients.Add(b, client); break; } await client.SendPacketAsync("VOICE_ACCEPT", new VoiceConnectionObject(b)); break; } }
private void Update() { if (GameManagerScript.GameState != 1) { return; } WSClient.UpdatePlayerInput(new PlayerInput() { DeviceId = WSConfig.DeviceId, DPad = TouchScreen.inNormal, UpArrow = Input.GetKey(KeyCode.UpArrow), DownArrow = Input.GetKey(KeyCode.DownArrow), RightArrow = Input.GetKey(KeyCode.RightArrow), LeftArrow = Input.GetKey(KeyCode.LeftArrow), }); PlayerChecker.transform.position = new Vector3(this.transform.position.x, this.transform.position.y + 100, 0); // Debug.Log(TouchScreen.inNormal); }
void Update() { if (_gameManager == null) { return; } WSClient.GetGameState(); var frameDelta = WSClientState.GameState.FrameCount - _lastFrameCount; if (frameDelta <= 0) { return; } WSClientState.GameState.FrameCount = _lastFrameCount; var gameState = WSClientState.GameState; _gameManager.ServerGameTime = gameState.GameTime; // ball _gameManager.Ball.transform.position = gameState.BallPosition; _gameManager.Ball.GetComponent <Rigidbody2D>().velocity = gameState.BallVelocity; // players var serverPlayers = gameState.PlayersState; if (gameState.PlayersState != null) { var clientPlayers = _gameManager.Players; foreach (var serverPlayer in serverPlayers) { if (!clientPlayers.ContainsKey(serverPlayer.DeviceId)) { continue; } LoadPlayer(clientPlayers[serverPlayer.DeviceId], serverPlayer, frameDelta); } } }
static void Main(string[] args) { try { var userId = "u1"; var Generation = 1; var Signature = "sig1"; var cl = new WSClient(new Uri("ws://localhost:56566/ws")); cl.Start(new WSClientData() { Generation = Generation, Signature = Signature, UserId = userId }).Wait(); using var channel = GrpcChannel.ForAddress("https://localhost:5001"); var client = new interfaces.IPresenceService.IPresenceServiceClient(channel); var reply1 = client.PresenceConnect(new PresenceConnectRequest() { UserId = userId, }); var reply2 = client.PresenceGetStateAndSub(new PresenceGetStateAndSubRequest() { UserId = userId, Token = cl.Token, }); while (true) { Thread.Sleep(100); } } catch (Exception e) { } }
public IEnumerable <TickerHistoryValue> LoadFromService(string strategyCode) { DateTime start = DateTime.Now; WSClient client = new WSClient(); client.ClientCredentials.UserName.UserName = ConfigurationManagerHelper.Default.WSUserName; client.ClientCredentials.UserName.Password = ConfigurationManagerHelper.Default.WSPassword; var result = client.getStrategyTickers(strategyCode); this.Log?.Invoke(new Core.Log() { Name = "TickerHistoryHelper.LoadFromService", Start = start, Input = strategyCode, Output = JsonConvert.SerializeObject(result), }); return(result.tickers.Select(A => new TickerHistoryValue() { Ticker = strategyCode, Date = A.date, Value = (decimal)A.rate, })); }
private static async Task testItemListAsync() { string aspKey = "micpg"; string customerKey = "kupac"; string password = "******"; string cookie = "39983830859dJFaogrSxpgIcfvfy1T"; System.IO.FileInfo f = new FileInfo(String.Format(@"C:\Temp\itemList_{0}.xml", DateTime.Now.ToString("ddMMyyyy_HH_mm"))); using (StreamWriter sw = f.AppendText()) { try { WSContext ctx = new WSContext(aspKey, customerKey, password, @"http://www.microline.hr/WebServices/MOL.asmx", @"C:\Temp", cookie); WSClient client = new WSClient(ctx); var report = await client.GetItemsFilteredAsync(null, "sam", "itemsFilteredSam"); sw.WriteLine(report); } catch (Exception ex) { sw.WriteLine(ex.Message); sw.WriteLine(ex.StackTrace); if (ex.InnerException != null) { sw.WriteLine(ex.InnerException.Message); sw.WriteLine(ex.InnerException.StackTrace); if (ex.InnerException.InnerException != null) { sw.WriteLine(ex.InnerException.InnerException.Message); sw.WriteLine(ex.InnerException.InnerException.StackTrace); } } } } }
void OnApplicationQuit() { WSServer.Stop(); WSClient.Disconnect(); }
private Task OnDisconnect(WSClient arg) { _clients.Remove(arg); _voiceClients.Remove(arg); return(Task.CompletedTask); }
private void GetInfo(HttpContext context) { string sUserId = context.Request["UserId"]; if (string.IsNullOrEmpty(sUserId)) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 5, "Chưa nhập đủ thông tin")); return; } if (sUserId.Trim().Length != 12 && sUserId.Trim().Length != 14) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 6, "Số thuê bao phải là 12 hoặc 14 ký tự")); return; } if (!Utility.isOnlyNumber(sUserId)) { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 7, "Số hợp đồng phải là kiểu số")); return; } WSClient client = new WSClient(); var cred = new credential { clientId = Config.ClientIdSmartLink }; var result = client.getVoucherPaymentInfo(cred, sUserId); if (result.returnCode != "") { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", result.returnCode, result.returnCodeDescription)); return; } else { CustomerGateInfo info = XMLReader.ReadInfo(result.responseData); if (info != null) { string sVoucher = ""; if (info.vouchers != null && info.vouchers.Count > 0) { foreach (voucher voucher in info.vouchers) { if (sVoucher == "") { sVoucher += string.Format("{{\"vouchervalue\":\"{0}\",\"duration\":\"{1}\",\"vouchername\":\"{2}\",\"durationuomaltcode\":\"{3}\",\"voucherdesc\":\"{4}\"}}", voucher.vouchervalue, voucher.duration, voucher.vouchername, voucher.durationuomaltcode, voucher.voucherdesc); } else { sVoucher += "," + string.Format("{{\"vouchervalue\":\"{0}\",\"duration\":\"{1}\",\"vouchername\":\"{2}\",\"durationuomaltcode\":\"{3}\",\"voucherdesc\":\"{4}\"}}", voucher.vouchervalue, voucher.duration, voucher.vouchername, voucher.durationuomaltcode, voucher.voucherdesc); } } } context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\",\"subnum\":\"{2}\",\"contactname\":\"{3}\",\"contactaddress\":\"{4}\"," + "\"contactphone\":\"{5}\",\"contactemail\":\"{6}\",\"servicename\":\"{7}\",\"substatusname\":\"{8}\"," + "\"expirationdate\":\"{9}\",\"vouchers\":[{10}] }}", 0, "load thông tin ok", info.subnum, info.contactname, info.contactaddress, info.contactphone, info.contactemail, info.servicename, info.substatusname, info.expirationdate, sVoucher)); context.Session[Config.GetSessionUser] = info; } else { context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 8, "Không tìm thấy thông tin khách hàng")); } } }
private string[] createProjectScope(BaseExtendable mtdProject, IMTDService service, WSProjectGroup projectGroup, string projName, string projDescription, WSLocale[] locales, string[] attachedFile, WSClient client, WSProjectType projectType) { string retVal = null; string[] custom = null; string debugLine; string pNum = ""; EntityVersion newVersion = new EntityVersion(); string[] entityIIDArray = createQuoteSectionAndAssessment(service, mtdProject, newVersion, projName, projDescription); string mtdProjID = mtdProject.OID; //to be used for project tracking code string WSProjID = projectGroup.getId; // TODO: the project tracking code should be the identifier for the Quote/Assessment relationship and the project number. As well as the WS project number. string projectTrackingCode = mtdProjID + "_" + WSProjID; entityIIDArray[2] = mtdProjID; entityIIDArray[3] = WSProjID; debugLine = DateTime.Now + " Project tracking code: " + projectTrackingCode; WriteDebugfile(debugLine); debugLine = DateTime.Now + " Entiry Array code: " + entityIIDArray[0] + ", " + entityIIDArray[1]; WriteDebugfile(debugLine); return(entityIIDArray); }
public ContactService() { WSClient.BaseAddress = ConfigurationManager.AppSettings["baseaddress"]; clientObj = new WSClient(); }
public string[] getScopeInfo(string srcName, string projName, string projDescription, string file, Code srcLocale, Code[] dstLocales, int localeCount, string datatype, BaseExtendable mtdProject, IMTDService service, string WS_Client_Name, string Project_Type, string quoteType, string WSurl, string ProjectNum, string[] projectAttribs) { string retVal = "success"; string FILE_NAME = "473263"; string workgroupName = "default"; string workflowName = "1. Translation Only"; string[] entityIIDArray = new string[4]; string update = "no"; string review = "no"; string client_review = "no"; if (projectAttribs != null) { foreach (string projectAtrib in projectAttribs) { if (projectAtrib == "update") { update = "yes"; } else if (projectAtrib == "review") { review = "yes"; } else if (projectAtrib == "client_review") { client_review = "yes"; } } } projName = projName.Replace("\\", "-"); projName = projName.Replace("/", "-"); projName = projName.Replace(":", "-"); string src_asset = srcName.Replace("\\", "/"); string WSuserName = ConfigurationSettings.AppSettings["WS_USR"]; string WSpwd = ConfigurationSettings.AppSettings["WS_PWD"]; WSContext ctx = new WSContext(WSuserName, WSpwd, WSurl); //http://172.20.20.36:8585/ws/services string debugLine = DateTime.Now + " Got WS context "; WriteDebugfile(debugLine); debugLine = DateTime.Now + " source asset name = " + src_asset; WriteDebugfile(debugLine); WSAisManager aisManager = ctx.getAisManager(); WSUserManager userMgr = ctx.getUserManager(); WSAssetManager assetMgr = ctx.getAssetManager(); WSWorkflowManager workflowMgr = ctx.getWorkflowManager(); WSQuoteManager quoteMgr = ctx.getQuoteManager(); WSScopeManager scopeMgr = ctx.getScopeManager(); Code mdlCode = null; Base.Text codeID = null; int ID = 0; codeID = srcLocale.Description_TID; ID = Convert.ToInt32(codeID.Text_IID.ToString()); debugLine = DateTime.Now + " Got src locale id= " + ID.ToString(); WriteDebugfile(debugLine); WSLocale wslocale = null; if (WS_Client_Name == "Seagate") { wslocale = userMgr.getLocale2(GetSeagateLocID(ID)); } else { wslocale = userMgr.getLocale2(ID); } if (wslocale == null) { throw new System.InvalidOperationException("Invalid src locale"); } try { WSWorkgroup workgroup = userMgr.getWorkgroup(workgroupName); WSWorkflow workflow = workflowMgr.getWorkflow(workflowName); //int pId = 13066; //tokenize dest locales //char[] sep = { ';' }; //String[] res = dstLocales.Split(sep); int numLocs = localeCount; //dstLocales.Length; WSLocale[] locales = null; Code targCode; locales = new WSLocale[numLocs]; for (int i = 0; i < numLocs; i++) { //string localeName = res[i].Trim(); targCode = dstLocales[i]; debugLine = DateTime.Now + " Got target locale code= " + targCode; WriteDebugfile(debugLine); if (targCode != null) { //mdlCode = Code.FindAltType("LOC", localeName); codeID = targCode.Description_TID; debugLine = DateTime.Now + " Got target locale codeID= " + codeID; WriteDebugfile(debugLine); ID = Convert.ToInt32(codeID.Text_IID.ToString()); debugLine = DateTime.Now + " Got target locale id= " + ID.ToString(); WriteDebugfile(debugLine); WSLocale locale = null; if (WS_Client_Name == "Seagate") { locale = userMgr.getLocale2(GetSeagateLocID(ID)); } else { locale = userMgr.getLocale2(ID); } locales[i] = locale; if (locale == null) { throw new System.InvalidOperationException("Error in target locale " + locale); } } else { throw new System.InvalidOperationException("Error in target code " + targCode); } } if (locales[0] == null) { throw new System.InvalidOperationException("No target locales defined"); } // WSClient[] ctxclients = ctx.getUser.get.getClients(); WSWorkflow DefaultWF = null; WSTm DefaultTm = null; WSClient client = userMgr.getClient(WS_Client_Name); WSProjectType projectType = null; // for (int o = 0; o < ctxclients.Length; o++) // { if (!(client == null)) { // client = ctxclients[o]; // WSProjectType[] ctxtypes = client.; String inProjType = Project_Type.Trim(); // inProjType = inProjType.Replace(" ",""); projectType = workflowMgr.getProjectType(inProjType); if (projectType == null) { throw new System.InvalidOperationException("No match in WS found for project type " + Project_Type); } // for (int p = 0; p < ctxtypes.Length; p++) // { // String projType = ctxtypes[p].getName.Trim(); // projType = projType.Replace(" ",""); // //if (String.Compare(projType, Project_Type) == 0) // if (projType.Equals(inProjType) ) // { // projectType = ctxtypes[p]; DefaultWF = projectType.getDefaultWorkflow; DefaultTm = projectType.getDefaultTm; debugLine = DateTime.Now + " Got project type " + projectType.getDisplayString; WriteDebugfile(debugLine); // break; // } // // } } else { throw new System.InvalidOperationException("Client Name does not exist \"" + WS_Client_Name + "\""); } // } string[] attachedFile = new string[1]; attachedFile[0] = src_asset; //file to 'attach' to project string[] custom = new string[2]; custom[0] = null; custom[1] = null; //custom ais properties try { string clientPath = "/Client Files/" + WS_Client_Name; if (clientPath == null) { debugLine = DateTime.Now + " Parameter clientPath cannot be null = " + clientPath; WriteDebugfile(debugLine); throw new System.ArgumentException("Parameter clientPath cannot be null", clientPath); } WSNode clientNode = aisManager.getNode(clientPath); string clientTempPath = clientPath + "/Temp"; if (clientTempPath == null) { aisManager.create(clientTempPath, clientNode); } WSNode clientTempNode = aisManager.getNode(clientTempPath); string aisPath = clientTempPath + "/Upload"; if (aisPath == null) { aisManager.create(aisPath, clientTempNode); } string oldPath = aisPath; WSNode oldNode = aisManager.getNode(oldPath); WSProjectGroup projectGroup = workflowMgr.createProjectGroup(ProjectNum + "-" + WS_Client_Name + "-" + projName, projDescription, locales, attachedFile, client, projectType, custom); WSProject[] theProjects = projectGroup.getProjects; foreach (WSProject theProject in theProjects) { theProject.setAttribute("update", update); theProject.setAttribute("review", review); theProject.setAttribute("creview", client_review); //string theLocaleString = "Target-" + theProject.getTargetLocale.getDisplayString; //WSTask[] theProjectTasks = theProject.getTasks(); //string theNodeString = ""; //string [] theNodeStringArray = theProjectTasks[0].getTargetPath.Split('/'); //int countHolder = 0; //for (int i = theNodeStringArray.Length -1; theNodeStringArray.Length > 0; i--) //{ // if ( theNodeStringArray[i].Equals(theLocaleString)) // { // countHolder = i; // break; // } //} //for (int j=1; j <= countHolder; j++) //{ // theNodeString += "/" + theNodeStringArray[j]; //} } debugLine = DateTime.Now + " Created WS Project Group = " + projectGroup.getId; WriteDebugfile(debugLine); entityIIDArray = createProjectScope(mtdProject, service, projectGroup, projName, projDescription, locales, attachedFile, client, projectType); } catch (Exception e) { debugLine = DateTime.Now + " " + e.Message; WriteDebugfile(debugLine); throw new System.InvalidOperationException(e.Message); } } catch (Exception e) { throw new System.InvalidOperationException(e.Message); } return(entityIIDArray); }
private static void Client_OnConnected(WSClient client) { ConsoleHelper.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " 当前客户端已连上"); }
public ChatClient(WSClient client, int clientId) { Client = client; ClientId = clientId; }
static void Main(string[] args) { ConsoleHelper.WriteLine("WSServer 正在初始化....", ConsoleColor.Green); _server.OnMessage += Server_OnMessage; _server.Start(); ConsoleHelper.WriteLine("WSServer 就绪,回车启动客户端", ConsoleColor.Green); ConsoleHelper.ReadLine(); WSClient client = new WSClient(); client.OnPong += Client_OnPong; client.OnMessage += Client_OnMessage; client.OnError += Client_OnError; client.OnDisconnected += Client_OnDisconnected; ConsoleHelper.WriteLine("WSClient 正在连接到服务器...", ConsoleColor.DarkGray); var connected = client.Connect(); if (connected) { ConsoleHelper.WriteLine("WSClient 连接成功,回车测试消息", ConsoleColor.DarkGray); ConsoleHelper.ReadLine(); //client.Close(); //ConsoleHelper.ReadLine(); var loop = true; Task.Run(() => { while (loop) { ConsoleHelper.WriteLine("WSClient 正在发送消息...", ConsoleColor.DarkGray); client.Send("hello world!"); Thread.Sleep(1000); } }); ConsoleHelper.ReadLine(); loop = false; ConsoleHelper.WriteLine("WSClient 正在ping服务器...", ConsoleColor.DarkGray); Thread.Sleep(2000); client.Ping(); ConsoleHelper.ReadLine(); ConsoleHelper.WriteLine("WSClient 正在断开连接..."); Thread.Sleep(1000); client.Close(); } else { ConsoleHelper.WriteLine("WSClient 连接失败", ConsoleColor.DarkGray); } ConsoleHelper.ReadLine(); }
/// <summary> /// Sync callback /// </summary> /// <param name="obj"></param> private void SyncCallback(IRestResponse obj) { if (obj.StatusCode == System.Net.HttpStatusCode.OK) { MessageService.message("Synchronisation réussie"); WSClient ws = new WSClient(); List <Client> clients = ws.JSONToListClients(obj.Content); DBClient dbc = new DBClient(); DBEstimation dbe = new DBEstimation(); foreach (Client client in clients) { Client clientFound = dbc.GetByIdServeur(client.IDServeur); client.IsSynchro = true; if (clientFound != null) { dbc.UpdateByIdServeur(client); } else { client.IDCommercial = Global.commercial.ID; dbc.Add(client); } clientFound = dbc.GetByIdServeur(client.IDServeur); // INSERT / UPDATE estimations des clients du commercial foreach (Estimation e in client.Estimations) { Estimation estimationFound = dbe.GetByIdServeur(e.IDServeur); e.IsSynchro = true; if (estimationFound != null) { dbe.UpdateByIdServeur(e); } else { e.IDClient = clientFound.ID; dbe.Add(e); } } } IEnumerable <Client> allClient = dbc.GetAll(); foreach (Client item in allClient) { bool canDelete = true; foreach (Client item2 in clients) { if (item.IDServeur == item2.IDServeur) { canDelete = false; break; } } if (canDelete == true) { dbc.Delete(item.ID); } } } else { MessageService.message("Synchronisation impossible"); } }
//판넬 키는 부분 void Update() { ScoreView.Set(Score.P1Score, Score.P2Score); TimerView.Set((int)ServerGameTime); if (GameState == 0) { if (Players.ContainsKey(WSConfig.DeviceId)) { ReadyButton.SetActive(false); } if (Init.DebugStandalone) { GameStart(); } else if (Players.Count >= 2) { WSClient.Join(); ReadyPanel.SetActive(false); Invoke("GameStart", 0.5f); } else { ReadyPanel.SetActive(true); } } else if (GameState == 1) { if (ServerGameTime < 0.0f || Score.P1Score == 10 || Score.P2Score == 10) { var maybeMyTeam = MyTeam; int myTeam = 0; if (maybeMyTeam.HasValue) { myTeam = maybeMyTeam.Value; } else { Debug.LogError("My player not found"); myTeam = 0; } GameState = 2; var meWinState = 0; ResultPanel.SetActive(true); if (Score.P1Score > Score.P2Score) { ManWin.SetActive(true); GirlLose.SetActive(true); meWinState = (myTeam == 0) ? 1 : -1; } else if (Score.P1Score == Score.P2Score) { ManLose.SetActive(true); GirlLose.SetActive(true); meWinState = 0; } else { ManLose.SetActive(true); GirlWin.SetActive(true); meWinState = (myTeam == 0) ? -1 : 1; } if (meWinState == 1) { WinButton.SetActive(true); } if (meWinState == 0) { DrawButton.SetActive(true); } if (meWinState == -1) { LoseButton.SetActive(true); } } } if (ResetServer && WSServer.IsRunning) { ResetServer = false; if (WSServerState.JoinedPlayers.Count < 2) { WSServerState.Reset(); } SceneManager.LoadScene("main"); } }
private void GateFTP(HttpContext context, string UserId, string CardSerials, string CardPin, string sType) { GateCardInfo info = new GateCardInfo() { UserId = UserId, CardId = CardPin, SerialsId = CardSerials, CreateDate = DateTime.Now, ServiceID = sType }; try { AuthenSoapHeader authen = new AuthenSoapHeader(); authen.UserName = Config.UserServicesGate; authen.Password = Config.PassServicesGate; WsGateCardSoapClient client = new WsGateCardSoapClient(); var result = client.CardInputSandbox(authen, sType, CardSerials, CardPin); if (result.ErrorCode == "00") { //Giao dịch GateCard thành công info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; info.Amount = int.Parse(result.Amount); info.TransId = result.TransId; SubmitVoucherInfo sbInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdFPT, UserId = UserId, Amount = info.Amount, CreateDate = DateTime.Now, TransId = info.TransId }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdFPT }; var wsResult = wsclient.submitVoucher(cred, UserId, result.Amount, info.TransId); sbInfo.returnCode = wsResult.returnCode; sbInfo.returnCodeDescription = wsResult.returnCodeDescription; sbInfo.responseData = wsResult.responseData; sbInfo.signature = wsResult.signature; if (sbInfo.returnCode == "") { string sDate = ReadResultVocher(sbInfo.responseData); context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 0, sDate)); return; } else { context.Response.Write(string.Format("{{\"error\":\"{0}\",\"msg\":\"{1}\"}}", sbInfo.returnCode, sbInfo.returnCodeDescription)); return; } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); sbInfo.returnCode = e.GetHashCode().ToString(); sbInfo.returnCodeDescription = e.Message; return; } finally { SubmitVoucherData.instance.Add(sbInfo); } } else { info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", result.ErrorCode, result.ErrorMessage)); } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); //if (info.ResultId == "") //{ // info.ResultId = e.GetHashCode().ToString(); // info.Msg = e.Message; //} return; } finally { GateCardData.instance.Add(info); } }
private void Update() { WSClient.HandleAllBroadcast(); }
public WebSocketFrameTester(Uri uri) { Client = new WSClient(uri); }