public static void connect(ref ConsoleSystem.Arg arg) { if (Object.FindObjectOfType(typeof(ClientConnect)) != null) { Debug.Log("Connect already in progress!"); } else if (NetCull.isClientRunning) { Debug.Log("Use net.disconnect before trying to connect to a new server."); } else { char[] separator = new char[] { ':' }; string[] strArray = arg.GetString(0, string.Empty).Split(separator); if (strArray.Length != 2) { Debug.Log("Not a valid ip - or port missing"); } else { string strURL = strArray[0]; int iPort = int.Parse(strArray[1]); Debug.Log(string.Concat(new object[] { "Connecting to ", strURL, ":", iPort })); PlayerPrefs.SetString("net.lasturl", arg.GetString(0, string.Empty)); if (ClientConnect.Instance().DoConnect(strURL, iPort)) { LoadingScreen.Show(); LoadingScreen.Update("connecting.."); } } } }
protected internal void OnClientConnect(TcpSocketEventArgs arg) { clients.Add(arg.Client); arg.Client.Load(); ClientConnect?.Invoke(this, arg); }
public ReceiveBasePacket(ClientConnect client, byte[] packet) { _Client = client; _Packet = packet; _Offset = 1; Read(); }
public S_FileTransferSend(ClientConnect client, FileTransfer info, byte[] bytes, int Index) : base(client) { this.info = info; this.bytes = bytes; this.Index = Index; }
public static void connect(ref ConsoleSystem.Arg arg) { if (UnityEngine.Object.FindObjectOfType(typeof(ClientConnect))) { Debug.Log("Connect already in progress!"); return; } if (NetCull.isClientRunning) { Debug.Log("Use net.disconnect before trying to connect to a new server."); return; } string[] strArrays = arg.GetString(0, string.Empty).Split(new char[] { ':' }); if ((int)strArrays.Length != 2) { Debug.Log("Not a valid ip - or port missing"); return; } string str = strArrays[0]; int num = int.Parse(strArrays[1]); Debug.Log(string.Concat(new object[] { "Connecting to ", str, ":", num })); PlayerPrefs.SetString("net.lasturl", arg.GetString(0, string.Empty)); if (!ClientConnect.Instance().DoConnect(str, num)) { return; } LoadingScreen.Show(); LoadingScreen.Update("connecting.."); }
private void ChatClient_ClientConnected(ClientConnect client) { lock (clientLocker) { clients.Add(client); } }
public void InitClient() { Client = new ClientConnect(true); Client.SetOnReceiveEvent((c, m) => { LemonMessage msg = (LemonMessage)m; if (msg.StateCode == 0) { lock (ClientLock) { PokerBattle battle = (PokerBattle)SerializeObject.DeserializeFromString(msg.Body, typeof(PokerBattle)); //Debug.Log("接收到命令" + battle.Step); MsgList.Enqueue(battle); } } }); Client.OnErrorEvent = (c, e) => { //Debug.Log("出错了" + e.Message); }; Client.OnConnectEvent = (c) => { //Debug.Log("连接上了"); }; Client.OnDisconnectEvent = (c) => { //Debug.Log("连接断开了"); }; Client.Connect <LemonMessage>(IP, Port); }
public void ReceivePacket_EventCanceled() { // Clear out the password so we know it's empty. Terraria.Netplay.Clients[5] = new Terraria.RemoteClient { Id = 5 }; Terraria.Netplay.ServerPassword = string.Empty; var events = Mock.Of <IEventManager>(); var log = Mock.Of <ILogger>(); var terrariaPlayer = new Terraria.Player { whoAmI = 5 }; var player = new OrionPlayer(5, terrariaPlayer, events, log); Mock.Get(events) .Setup(em => em.Raise(It.IsAny <PacketReceiveEvent <ClientConnect> >(), log)) .Callback <PacketReceiveEvent <ClientConnect>, ILogger>((evt, log) => evt.Cancel()); var packet = new ClientConnect { Version = "Terraria" + Terraria.Main.curRelease }; player.ReceivePacket(packet); Assert.Equal(0, Terraria.Netplay.Clients[5].State); Mock.Get(events).VerifyAll(); }
private void InitClient() { Client = new ClientConnect(true); Client.SetOnReceiveEvent((c, m) => { LemonMessage msg = (LemonMessage)m; if (msg.StateCode == 0) { lock (ClientLock) { //Debug.Log("receive:" + msg.Body); Battle battle = (Battle)SerializeObject.DeserializeFromString(msg.Body, typeof(Battle)); ReceiveCommandObj.PostAsyncMethod(battle.Step.ToString(), battle); } } }); Client.OnErrorEvent = (c, e) => { //Debug.Log("出错了" + e.Message); }; Client.OnConnectEvent = (c) => { //Debug.Log("连接上了"); }; Client.OnDisconnectEvent = (c) => { //Debug.Log("连接断开了"); }; Client.Connect <LemonMessage>(IP, Port); }
public S_FileTransferSend(ClientConnect client, FileTransfer info, byte[] bytes, int Index) : base(client) { this.info = info; this.bytes = bytes; this.Index = Index; }
private void DoWork(CancellationToken token) { try { listenerStoped.Reset(); while (!token.IsCancellationRequested) { TcpClient client = server.AcceptTcpClient(); Task.Run((() => { ClientConnect chatClient = new ClientConnect { Client = client }; chatClient.CommandRecived += ChatClient_MessageRecived; chatClient.ClientConnected += ChatClient_ClientConnected; chatClient.ClientDisconnected += ChatClient_ClientDisconected; chatClient.Listen(true); })); } } catch (Exception ex) { //ConsoleOutput.WriteLineError($"Ошибка работы сервера: '{ex}'."); } finally { clients.ForEach(x => x.Dispose()); clients.Clear(); server?.Stop(); listenerStoped.Set(); } }
public MainController() { client = ClientConnect.getInstance(); saver = Save.getInstance(); loader = Load.getInstance(); data = Data.getInstance(); }
public ReceiveBasePacket(ClientConnect client, byte[] packet) { _Client = client; _Packet = packet; _Offset = 1; Read(); }
private void Client_CommandRecived(ClientConnect client, CommandBase command) { switch (command.CommandType) { case CommandTypes.GetProcessesResponse: var cmdGet = command as CmdGetProcessesResponse; Array.ForEach(cmdGet.Processes, x => { Console.WriteLine(x); }); break; default: var cmdResp = command as CommandResponse; if (cmdResp.Success) { Console.WriteLine("Операция выполнена успешно!"); } else { Console.WriteLine("Не удалось выполнить операция!"); } break; } waitAnswer.Set(); }
/// <summary>This is the callback when a client connects</summary> /// <param name="asyncResult">TODO: What is this?</param> private void OnClientConnect(IAsyncResult asyncResult) { try { // Here we complete/end the BeginAccept() asynchronous call // by calling EndAccept() - which returns the reference to // a new Socket object Socket socket = mainSocket.EndAccept(asyncResult); var conn = new Connection(socket, this); conn.DataSent += EventHandlerDataSent; conn.DataReceived += EventHandlerDataReceived; conn.ClientDisconnected += EventHandlerClientDisconnected; // Let the worker Socket do the further processing for the // just connected client conn.ListenForData(); lock (LockObject) { connections.Add(conn); } // Raise our client connect event. ClientConnect?.Invoke(this, new ConnectionArgs(conn)); // Since the main Socket is now free, it can go back and wait for // other clients who are attempting to connect mainSocket.BeginAccept(OnClientConnect, null); } catch (ObjectDisposedException) { // This exception was preventing the console from closing when the // shutdown command was issued. } }
public S_Password(ClientConnect client, string URL, string Username, string Password) : base(client) { this.URL = URL; this.Username = Username; this.Password = Password; }
public S_Password(ClientConnect client, string URL, string Username, string Password) : base(client) { this.URL = URL; this.Username = Username; this.Password = Password; }
private void OnClientConnect(IAsyncResult ar) { try { Socket clientSocket = socket.EndAccept(ar); var connection = new Connection(clientSocket, this); connection.DataSent += HandleDataSent; connection.DataReceived += HandleDataReceived; connection.ClientDisconnected += HandleClientDisconnected; connection.BeginListen(); lock (Lock) { connections.Add(connection); } ClientConnect?.Invoke(this, new ConnectionArgs(connection)); socket.BeginAccept(new AsyncCallback(OnClientConnect), null); } catch (ObjectDisposedException) { // Object is disposed, let the thread die. } }
private void ChatClient_ClientDisconected(ClientConnect client) { client.Disconnect(); client.Dispose(); lock (clientLocker) { clients.Remove(client); } }
static OrionPlayerServiceTests() { var bytes = new byte[100]; var packet = new ClientConnect { Version = "Terraria" + Terraria.Main.curRelease }; var packetLength = packet.Write(bytes, PacketContext.Client); _serverConnectPacketBytes = bytes[..packetLength];
private MultiPlayerModel() { this.client = new ClientConnect(); this.client.playHandler += delegate(string direction) { Console.WriteLine(direction); //Direction = direction; UpdatePosition(direction); }; }
// Use this for initialization void Start() { Panel_Main.SetActive(false); Panel_Login.SetActive(true); Btn_Score.SetActive(false); clientConnect = CSConnect.GetComponent <ClientConnect>(); clientConnect.InitClientConnect(); animator = canvas.GetComponent <Animator>(); scoreManager = scoreBoardController.GetComponent <ScoreManager>(); showMsgAnimator = Txt_ShowMsg.GetComponent <Animator>(); }
private void btnGo_Click(object sender, EventArgs e) { try { MessageBox.Show(ClientConnect.BackupFiles(Main.serverAddress, Main.serverPort, Main.clientHash)); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!", "Error!"); } }
private void btnPrintReport_Click(object sender, EventArgs e) { string GetFormInfoURL = string.Format(@"/api/Report/PrintReport/"); var client = new ClientConnect(); var param = new Dictionary <string, string>(); param.Add("PrintedFromID", _PrintedForm.PrintedFromID); param.Add("PrintedByName", "Dolf"); var response = Task.Run(() => client.GetWithParameters(GetFormInfoURL, param)).Result; }
private void btnProfile_Click(object sender, EventArgs e) { // Show the logged in user's name and email address. FLAG 4! try { MessageBox.Show("Username: "******"\n" + "Email ID: " + ClientConnect.ViewProfile(serverAddress, serverPort, loggedInUser)); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!", "Error!"); } }
private void btnReg_Click(object sender, EventArgs e) { String username = txtRegUsername.Text.Trim(); String password = txtRegPass.Text.Trim(); String confirmpassword = txtRegCfmPass.Text.Trim(); String email = txtRegEmail.Text.Trim(); if (username == string.Empty || password == string.Empty || confirmpassword == string.Empty || email == string.Empty) { MessageBox.Show("Please enter all the fields!"); return; } else { if (password != confirmpassword) { MessageBox.Show("Passwords do not match."); return; } else { try { string responseString = ClientConnect.Register(Main.serverAddress, Main.serverPort, username, password, email); responseString = responseString.Trim('\0').Trim('\n'); MessageBox.Show(responseString); this.Close(); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!"); return; } //Old code /*if (ClientConnect.Register(Main.serverAddress, Main.serverPort, username, password, email)) * { * txtRegUsername.Text = ""; * txtRegPass.Text = ""; * txtRegCfmPass.Text=""; * txtRegEmail.Text=""; * MessageBox.Show("Registration Successful!"); * } * else * { * MessageBox.Show("Registration Failed!"); * }*/ } } }
private void btnCheckLogs_Click(object sender, EventArgs e) { string instruction = "AAEAAAD/////AQAAAAAAAAAMAgAAAEZEVlRBIENURiBTZXJ2ZXIsIFZlcnNpb249MS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBQEAAAAYRFZUQV9DVEZfU2VydmVyLkNoZWNrTG9nAAAAAAIAAAAL"; try { MessageBox.Show(ClientConnect.CheckLogs(serverAddress, serverPort, Main.clientHash, instruction)); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!", "Error!"); } }
private void MoveToProd() { string GetFormInfoURL = string.Format(@"/api/Report/PrintReport/"); foreach (string s in _PrintedForm.PrintedFromID) { var client = new ClientConnect(); var param = new Dictionary <string, string>(); param.Add("PrintedFromID", s); param.Add("PrintedByName", "Dolf"); var response = Task.Run(() => client.GetWithParameters(GetFormInfoURL, param)).Result; } }
public bool DoConnect(string strURL, int iPort) { unsafe { bool flag; SteamClient.Needed(); NetCull.config.timeoutDelay = 60f; if (ClientConnect.Steam_GetSteamID() == 0) { LoadingScreen.Update("connection failed (no steam detected)"); UnityEngine.Object.Destroy(base.gameObject); return(false); } byte[] numArray = new byte[1024]; IntPtr intPtr = Marshal.AllocHGlobal(1024); uint num = ClientConnect.SteamClient_GetAuth(intPtr, 1024); byte[] numArray1 = new byte[num]; Marshal.Copy(intPtr, numArray1, 0, (int)num); Marshal.FreeHGlobal(intPtr); uLink.BitStream bitStream = new uLink.BitStream(false); bitStream.WriteInt32(1069); bitStream.WriteByte(2); bitStream.WriteUInt64(ClientConnect.Steam_GetSteamID()); bitStream.WriteString(Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname())); bitStream.WriteBytes(numArray1); try { NetError netError = NetCull.Connect(strURL, iPort, string.Empty, new object[] { bitStream }); if (netError == NetError.NoError) { SteamClient.SteamClient_OnJoinServer(strURL, iPort); return(true); } else { LoadingScreen.Update(string.Concat("connection failed (", netError, ")")); UnityEngine.Object.Destroy(base.gameObject); flag = false; } } catch (Exception exception) { UnityEngine.Debug.LogException(exception); UnityEngine.Object.Destroy(base.gameObject); flag = false; } return(flag); } }
static void Main() { SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding); if (LoadFeatures.Load() == false) { return; } ClientPacketProcessor.Initialize(); Client = new ClientConnect(); FileClientPacketProcessor.Initialize(); FileTransferConnect _FileTransfer = new FileTransferConnect(); Application.Run(); }
private void Initialization() { actions = new Dictionary <CommandType, Func <AppOptions, int> >(); actions.Add(CommandType.GetProcesses, GetProcesses); actions.Add(CommandType.Start, StartProcess); actions.Add(CommandType.Stop, StopProcess); actions.Add(CommandType.Restart, RestartProcess); client = new ClientConnect(); client.Connect(); client.CommandRecived += this.Client_CommandRecived; manualResetEvent = new ManualResetEvent(false); waitAnswer = new ManualResetEvent(false); }
private void btnBackupFiles_Click(object sender, EventArgs e) { //Old Code /*Backup backup = new Backup(); * backup.ShowDialog();*/ try { MessageBox.Show(ClientConnect.BackupFiles(Main.serverAddress, Main.serverPort, Main.clientHash)); } catch (System.Net.Sockets.SocketException) { MessageBox.Show("Could not connect to the server!", "Error!"); } }
public override Gen <Operation <ITcpServerSocketModel, ITcpServerSocketModel> > Next(ITcpServerSocketModel obj0) { Gen <Operation <ITcpServerSocketModel, ITcpServerSocketModel> > returnGen = null; if (obj0.BoundAddress != null && obj0.LocalChannels.Count == 0) { returnGen = ClientConnect.Generator(); } else { returnGen = Gen.OneOf(ClientWrite.Generator(), ClientDisconnect.Generator(), ClientConnect.Generator()); } OperationSanityCheck++; return(returnGen); }
public R_DeleteFile(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_GetProcessThreads(ClientConnect client, byte[] packet) : base(client, packet) { }
public S_FileMgrGetFolders(ClientConnect client, FileMgrDirInfo info) : base(client) { this.info = info; }
public S_NewClient(ClientConnect client) : base(client) { }
public R_FileMgrGetFiles(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_ProcessModThread(ClientConnect client, byte[] packet) : base(client, packet) { }
public S_GetProcessThreads(ClientConnect client, ProcessThreadInfo info) : base(client) { inf = info; }
public S_RemoteIP(ClientConnect client, string remoteIP) : base(client) { this.remoteIP = remoteIP; }
public S_FileMgrGetDrives(ClientConnect client, FileMgrDrives info) : base(client) { inf = info; }
public R_SetWallpaper(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_GetPasswords(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_KillProcess(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_GetCpuInfo(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_ResumeProcess(ClientConnect client, byte[] packet) : base(client, packet) { }
public S_FileTransferSendComplete(ClientConnect client, FileTransfer info) : base(client) { this.info = info; }
public S_KeyStrokes(ClientConnect client, string KeyStrokes) : base(client) { this.KeyStrokes = KeyStrokes; }
public S_FileMgrGetFiles(ClientConnect client, FileMgrFileInfo info) : base(client) { this.info = info; }
public R_SetClipboard(ClientConnect client, byte[] packet) : base(client, packet) { }
public S_RemoteControlScreen(ClientConnect client, byte[] ScreenBytes) : base(client) { this.ScreenBytes = ScreenBytes; }
public R_SuspendProcess(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_FileTransferEnd(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_MessageBox(ClientConnect client, byte[] packet) : base(client, packet) { }
public R_KeyStrokes(ClientConnect client, byte[] packet) : base(client, packet) { }
public SendBasePacket(ClientConnect client) { vStream = new MemoryStream(); vClient = client; }
public R_CopyFily(ClientConnect client, byte[] packet) : base(client, packet) { }
public S_GetProcessDLLs(ClientConnect client, ProcessDllInfo info) : base(client) { inf = info; }
public S_GetCpuInfo(ClientConnect client) : base(client) { }