private void Start() { tcp = new TCP(); udp = new UDP(); ScoreManager = FindObjectOfType <Score> (); // ConnectToServer(SERVER_IP, SERVER_PORT); }
public Client(int _clientId) { id = _clientId; joinedRoomId = 0; tcp = new TCP(id); udp = new UDP(id); }
private void Start() { tcp = new TCP(); udp = new UDP(); match = new TCP(); }
public static void Start() { tcp = new TCP(); udp = new UDP(); instance = new Client(); }
public ServerClient(int _clientId, Server server) { id = _clientId; tcp = new TCP(id, this); udp = new UDP(id, this); this.server = server; }
private static void Main() { AppDomain.CurrentDomain.UnhandledException += UnhandledException; var sw = new Stopwatch(); sw.Start(); Console.CursorVisible = false; Cli.WriteHeader(Localization.Get("Title"), Localization.Get("Header"), ConsoleColor.Red); Cli.LoadingTitle(); Logger.Progress(0, ProgressStep); //Logger Settings Up Logger.Archive = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Logs"); Logger.LogFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Logs", "Comidat.log"); Logger.Progress(1, ProgressStep); //Console commands activating var console = new ConsoleCommands(); //Logger.Hide ^= LogLevel.Debug; Logger.Progress(2, ProgressStep); //Settings up server IServer server = new TCP(); server.Connected += ServerOnConnected; server.Disconnected += ServerOnDisconnected; server.MessageReceived += ServerOnMessageReceived; server.StartAsync(new IPEndPoint(IPAddress.Any, 5757)); Logger.Progress(3, ProgressStep); //Settings up Database //Global.Database.Database.Migrate(); Logger.Progress(4, ProgressStep); //Seed TBLReaders for testing //Global.SeedReaders(); //Global.SeedTags(); //Global.Database.SaveChanges(); Logger.Progress(5, ProgressStep); Global.LoadReaders(); Logger.Progress(6, ProgressStep); //Global.SeedForTestFromFile(); Logger.Progress(ProgressStep, ProgressStep); Logger.Info(Localization.Get("Comidat.Program.MainB.LoadingTime"), sw.ElapsedMilliseconds); sw.Stop(); Cli.RunningTitle(); //Test().Wait(0); Global.SaveDataBaseAync().Wait(0); console.Wait(); }
public Client(int _clientId, Server _server) { id = _clientId; tcp = new TCP(id); udp = new UDP(id); server = _server; }
public void Connect() { tcp = new TCP(HandlePacket, Disconnect, OnConnectInvoked, OnConnectionFailedInvoked, (int _id) => { id = _id; }); isConnected = true; tcp.Connect(ip, port); }
private void PerformCloseByPS2() { client.Close(); Console.Error.WriteLine("PS2 has closed connection"); //Connection Close Part 2, Send ACK to PS2 ReceivedSequenceNumbers.RemoveAt(0); ReceivedSequenceNumbers.Add(ExpectedSequenceNumber); unchecked { ExpectedSequenceNumber += 1; } TCP ret = CreateBasePacket(); ret.ACK = true; ret.FIN = true; recvbuff.Add(ret); state = TCPState.ConnectionClosedByPS2AndRemote; lock (sentry) { OldMyNumber = MySequenceNumber; unchecked { MySequenceNumber += (1); } } }
static void Main(string[] args) { Console.WriteLine("IP:"); string IP = Console.ReadLine(); Console.WriteLine("PORT:"); int port = int.Parse(Console.ReadLine()); Console.WriteLine("Mission Name:"); string missionName = Console.ReadLine(); double time = 0; while (true) { List <Image> images = new List <Image>(); images.Add(Image.FromFile(@"andrzej1.jpg")); images.Add(Image.FromFile(@"andrzej2.jpg")); images.Add(Image.FromFile(@"andrzej3.jpg")); images.Add(Image.FromFile(@"andrzej4.jpg")); images.Add(Image.FromFile(@"andrzej5.jpg")); foreach (var image in images) { TCP.Connect(IP, "SendUpdate " + missionName + " Images " + time + " " + Base64.ImageToBase64(image, ImageFormat.Jpeg), port); time += 0.2; Thread.Sleep(5000); } } }
//On Close by PS2 //S1: PS2 Sends FIN+ACK //S2: CloseByPS2Stage1_2 sends ACK, state set to Closing_ClosedByPS2 //S3: When server closes socket, we send FIN in CloseByPS2Stage3 //and set state to Closing_ClosedByPS2ThenRemote_WaitingForAck //S4: PS2 then Sends ACK //Connection Closing Finished in CloseByPS2Stage4 private bool CloseByPS2Stage1_2(TCP tcp) { Log_Info("PS2 has closed connection"); ErrorOnNonEmptyPacket(tcp); //Sending FIN with data receivedPS2SeqNumbers.RemoveAt(0); receivedPS2SeqNumbers.Add(expectedSeqNumber); unchecked { expectedSeqNumber += 1; } //lock (clientSentry) //{ client.Shutdown(SocketShutdown.Send); //} //Connection Close Part 2, Send ACK to PS2 TCP ret = CreateBasePacket(); ret.ACK = true; PushRecvBuff(ret); state = TCPState.Closing_ClosedByPS2; return(true); }
private void ConsoleInput_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13) { ConsoleOutputList.Add(ConsoleInput.Text); ConsoleOutputList.Add(TCP.Connect(Mission.IP, ConsoleInput.Text, Mission.port)); ConsoleInput.Text = ""; GenerateText(); ConsoleWindow.Text = ConsoleOutput; remebered = ConsoleOutputList.Count; } if (e.KeyValue == 38) { if (remebered - 2 > 0) { remebered -= 2; ConsoleInput.Text = ConsoleOutputList[remebered]; } } if (e.KeyValue == 40) { if (remebered + 2 < ConsoleOutputList.Count) { remebered += 2; ConsoleInput.Text = ConsoleOutputList[remebered]; } else { ConsoleInput.Text = ""; } } }
private void Start() { tcp = new TCP(); udp = new UDP(); StartCoroutine(AutoConnect()); }
public void Disconnect() { if (isConnected) { GameManager.HandleClientDisconnect(); isConnected = false; tcp.Disconnect(); tcp = null; udp.Disconnect(); udp = null; ServerManagerTCP.Disconnect(); ServerManagerTCP = null; UnityEngine.Debug.Log("Disconnected from server."); OnConnectionChanged(new ClientConnectionEventArgs() { Success = !isConnected, Type = ClientConnectionEvent.Disconnect }); PlayerDisconnected?.Invoke(this, EventArgs.Empty); } }
private async static Task <string> getUserInput(byte[] buffer) { await TCP.GetStream().ReadAsync(buffer, 0, buffer.Length); //await TCP.GetStream().ReadAsync(new byte[10]); return(Encoding.UTF8.GetString(buffer).Trim().Replace("\0", String.Empty)); }
static Task Main(string[] args) { Console.WriteLine("__________STARTING REST-SERVER__________"); TCP tcpHandler = null; var tasks = new List <Task>(); tasks.Add(Task.Run(() => TournamentMaster(10000))); try { tcpHandler = new TCP(); while (true) { ConcurrentConnections.Wait(); tasks.Add(Task.Run(() => ClientReception(tcpHandler))); } } catch (Exception e) { Console.WriteLine(e); throw; } finally { tcpHandler?.Stop(); Task.WaitAll(tasks.ToArray()); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) => { //drop the error to log file and exit using (var sw = new StreamWriter(Path.Combine(Bot.RootDirectory, "error.log"), true)) { var e = (eventArgs.ExceptionObject as Exception); sw.WriteLine(e.Message); sw.WriteLine(e.StackTrace); if (eventArgs.IsTerminating) { Environment.Exit(5); } } }; //get the version of the bot and set the window title Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; Console.Title = $"Werewolf Moderator {version}"; //Initialize the TCP connections TCP.Initialize(); //Let the nodes reconnect Thread.Sleep(1000); //start up the bot new Thread(Bot.Initialize).Start(); new Thread(NodeMonitor).Start(); //now pause the main thread to let everything else run Thread.Sleep(-1); }
public static void Disconnect() { TCP.Close(); TCP.Dispose(); TCP = null; listener = null; }
void Awake() { instance = this; DontDestroyOnLoad(this); lh = new Framework.Log.LogHandler(); var config = new ServerConfig(); var coder = new Coder(); TCPInstance = new TCP(config, coder); UpdateActions += TCPInstance.DoActions; TCPInstance.Connect(); UIInstance = new UIManager(); var userDataInst = UserData.Instance; var roomInst = Lobby.Instance; var battleInst = BattleData.Instance; var dialogInst = Dialog.Instance; Screen.sleepTimeout = SleepTimeout.NeverSleep; SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.sceneUnloaded += SceneManager_sceneUnloaded; AssetBundleManager.Instance.LoadManifestAsyn(m => { /*SceneManager.LoadScene(1);*/ }, () => { }); UIInstance.PushWindowFromResource(WindowType.Loading, WinMsg.None); }
/// <summary> /// /// </summary> /// <param name="conn"></param> /// <param name="protocoBase"></param> public void Register(TCP conn, ProtocolBase protocoBase) { ProtocolBytes protoco = (ProtocolBytes)protocoBase; object[] vs = protoco.GetDecode(); string protoName = vs[0].ToString(); string strFromat = "[收到注册协议]" + conn.GetAddress(); protoco = new ProtocolBytes(); protoco.SetProtocol(Fursion_Protocol.Register); UserData UD = JsonConvert.DeserializeObject <UserData>(vs[1].ToString()); string Openid = UD.Openid; string NickName = UD.NickNeam; Console.WriteLine(strFromat + " " + Openid + " " + NickName); var reg = DataMgr.instance.Register(Openid, NickName, UD); if (reg) // { protoco.AddData(0); // } else { protoco.AddData(1); conn.Send(protoco); return; } conn.Send(protoco); Console.WriteLine("**&&**&&**"); }
public void TeamStart(TCP conn, ProtocolBase protocoBase) { if (conn.Player.TeamOpenid != null) { TeamMC.A.TeamDict[conn.Player.TeamOpenid].StartGameing(); } }
public void TeamInvitation(TCP conn, ProtocolBase protocoBase) { ProtocolBytes bytes = (ProtocolBytes)protocoBase; object[] vs = bytes.GetDecode(); TeamMC.A.TeamInvitation(conn.Player, vs); }
private void Start() { tcp = new TCP(); udp = new UDP(); ConnectToServer(); }
//PS2 Sending ACK on half-open connection private bool SendNoData(TCP tcp) { if (tcp.SYN == true) { Log_Error("Attempt to Connect to an open Port"); throw new Exception("Attempt to Connect to an open Port"); } for (int i = 0; i < tcp.Options.Count; i++) { switch (tcp.Options[i].Code) { case 0: //End case 1: //Nop continue; case 8: lastRecivedTimeStamp = ((TCPopTS)(tcp.Options[i])).SenderTimeStamp; break; default: Log_Error("Got Unknown Option " + tcp.Options[i].Code); throw new Exception("Got Unknown Option " + tcp.Options[i].Code); //break; } } ErrorOnNonEmptyPacket(tcp); return(true); }
private bool CloseByRemoteStage3_4(TCP tcp) { Log_Info("PS2 has closed connection after remote"); ErrorOnNonEmptyPacket(tcp); receivedPS2SeqNumbers.RemoveAt(0); receivedPS2SeqNumbers.Add(expectedSeqNumber); unchecked { expectedSeqNumber += 1; } client.Shutdown(SocketShutdown.Send); TCP ret = CreateBasePacket(); ret.ACK = true; PushRecvBuff(ret); state = TCPState.Closing_ClosedByRemoteThenPS2_WaitingForAck; return(CloseByRemoteStage2_ButAfter4(tcp)); }
public Player(Server server) { Server = server; Udp = new UDP(this); Tcp = new TCP(this); }
//CheckNumbers //PerformCloseByPS2 //PerformCloseByRemote private TCP CreateBasePacket(byte[] data = null) { Log_Verb("Creating Base Packet"); if (data == null) { data = new byte[0]; } TCP ret = new TCP(data); //and now to setup THE ENTIRE THING ret.SourcePort = destPort; ret.DestinationPort = srcPort; ret.SequenceNumber = GetMyNumber(); Log_Verb("With MySeq: " + ret.SequenceNumber); ret.AcknowledgementNumber = expectedSeqNumber; Log_Verb("With MyAck: " + ret.AcknowledgementNumber); //ret.WindowSize = 16 * 1024; ret.WindowSize = (UInt16)(2 * maxSegmentSize); //default 2920B (2.85KB) if (sendTimeStamps) { ret.Options.Add(new TCPopNOP()); ret.Options.Add(new TCPopNOP()); ret.Options.Add(new TCPopTS((UInt32)timeStamp.Elapsed.TotalSeconds, lastRecivedTimeStamp)); } return(ret); }
private NumCheckResult CheckNumbers(TCP tcp) { ACKMyNumber = true; if (tcp.AcknowledgementNumber != MySequenceNumber) { ACKMyNumber = false; Console.Error.WriteLine("Unexpected Acknowledgement Number, Got " + tcp.AcknowledgementNumber + " Expected " + MySequenceNumber); if (tcp.AcknowledgementNumber != OldMyNumber) { throw new Exception("Unexpected Acknowledgement Number did not Match Old Number of " + OldMyNumber); } } if (tcp.SequenceNumber != ExpectedSequenceNumber) { if (tcp.GetPayload().Length == 0) { Console.Error.WriteLine("Unexpected Sequence Number From Act Packet, Got " + tcp.SequenceNumber + " Expected " + ExpectedSequenceNumber); } else { if (ReceivedSequenceNumbers.Contains(tcp.SequenceNumber)) { Console.Error.WriteLine("Got an Old Seq Number on an Data packet"); return(NumCheckResult.GotOldData); } else { throw new Exception("Unexpected Sequence Number From Data Packet, Got " + tcp.SequenceNumber + " Expected " + ExpectedSequenceNumber); } } } return(NumCheckResult.OK); }
public void ConnectToServer(string addr = IP_ADDRESS) { Debug.Log($"Calling tcp.Connect() | Socket: {addr}:{PORT}"); InitializeClientData(); tcp = new TCP(); tcp.Connect(addr, PORT); }
public Client(int _clientId) { id = _clientId; isReady = false; tcp = new TCP(id); udp = new UDP(id); }
public override bool OnConnect(TCP.Client Client, System.Net.IPEndPoint IP) { if (IP.Address.ToString() != "127.0.0.1") //deny the connection. return false; return true; //With this function you can also Modify the Socket, as it's stored in e.Client.Sock. }
public virtual ProsthesisStateBase OnDisconnection(TCP.ConnectionState state) { if (state == mContext.AuthorizedConnection) { //return new Shutdown(mContext); } return this; }
//클라이언트에서 사용할 때. public NetworkController(string serverAddress) { hostType = HostType.Client; GameObject nObj = GameObject.Find("Network"); network = nObj.GetComponent<TCP>(); network.Connect(serverAddress, PORT); }
public NetworkController() { hostType = HostType.Server; GameObject nObj = GameObject.Find("Network"); network = nObj.GetComponent<TCP>(); istrue=network.StartServer(PORT, 1); }
public override ProsthesisStateBase OnProsthesisCommand(ProsthesisCore.ProsthesisConstants.ProsthesisCommand command, TCP.ConnectionState from) { switch (command) { case ProsthesisCore.ProsthesisConstants.ProsthesisCommand.Resume: return new ProsthesisActive(mContext, mArduinos); } return base.OnProsthesisCommand(command, from); }
public virtual ProsthesisStateBase OnProsthesisCommand(ProsthesisCore.ProsthesisConstants.ProsthesisCommand command, TCP.ConnectionState from) { switch (command) { case ProsthesisCore.ProsthesisConstants.ProsthesisCommand.Shutdown: return new Shutdown(mContext); default: return this; } }
public override ProsthesisStateBase OnProsthesisCommand(ProsthesisCore.ProsthesisConstants.ProsthesisCommand command, TCP.ConnectionState from) { switch (command) { case ProsthesisCore.ProsthesisConstants.ProsthesisCommand.Initialize: return new RunSelfTest(mContext, mArduinos); case ProsthesisCore.ProsthesisConstants.ProsthesisCommand.Shutdown: return new Shutdown(mContext); } return this; }
public WinPCapObject(SnifferUI.DICOMSniffer mainObj, string Filename, TCP.TCPParser TCP) { tcp = TCP; snifferObj = mainObj; file = new FileStream(Filename,FileMode.Open,FileAccess.Read); uint magicNumber = Function.Get4BytesFromStream(file,Const.NORMAL); BaseTime = new DateTime(1970,1,1,1,2,3,123); switch(magicNumber) { case 0xD4C3B2A1: FileFormat = Format.WINPCAP; file.Position = 24; break; case 0x58435000: // "XCP" file.Position = 6; ushort versionNumber = Function.Get2BytesFromStream(file,Const.NORMAL); if(versionNumber == 0x312E) { FileFormat = Format.XCP001; } else { FileFormat = Format.XCP002; } file.Position = 12; BaseTime += new TimeSpan(((long)Function.Get4BytesFromStream( file , Const.VALUE ))*10000000); file.Position = 52; BaseTime -= new TimeSpan(((long)Function.Get8BytesFromStream( file , Const.VALUE ))*10); file.Position = 128; break; case 0x736E6F6F: // Sun snoop FileFormat = Format.SUNSNOOP; file.Position = 16; break; default: throw new Exception("Only the winpcap format (NA sniffer (windows 1.1) is supported. Unable to load capture file."); } // Sets the progress bar's minimum value to a number // representing the current position in file before the files are read in. snifferObj.Invoke(snifferObj.MinProgressHandler, new object[] { (int)file.Position }); // Sets the progress bar's maximum value to a number // representing the total length of the file. snifferObj.Invoke(snifferObj.MaxProgressHandler, new object[] { (int)file.Length }); }
public static ThrottleTransportAdapter.Direction Proto2Direction(TCP.Direction dir) { switch (dir) { case Direction.Send: return ThrottleTransportAdapter.Direction.Send; case Direction.Receive: return ThrottleTransportAdapter.Direction.Receive; case Direction.Both: default: return ThrottleTransportAdapter.Direction.Both; } }
public DiscoveryUC() { InitializeComponent(); if (null == App.discovery) App.discovery = new Discovery(); if (null == App.Devices) App.Devices = new ObservableCollection<Device>(); tcp = new TCP(); this.DataContext = this; }
//private string httpString = "HTTP/1.1"; public override void OnDataReceived(object sender, TCP.DataEventArgs e) { /*//Modify data. int Location = e.Buffer.FindString(httpString); if (Location != -1) { //find end of location. int EndHTTP = e.Buffer.FindString(" ", Location + 1); //replace between these two values. if (EndHTTP != -1) { e.Buffer = e.Buffer.ReplaceBetween(Location, EndHTTP, Encoding.ASCII.GetBytes("HTTP/1.0")); Console.WriteLine(Encoding.ASCII.GetString(e.Buffer, 0, e.Count)); //convert sender. } }*/ }
public override Plugin.LoginStatus HandleLogin(TCP.User user) { return (user.Username == "test" && user.Password == "testing1234" && user.IP.ToString().StartsWith("192.168.1.") ? LoginStatus.Correct : LoginStatus.Denied); }
public virtual ProsthesisStateBase OnConnection(TCP.ConnectionState state) { return this; }
public virtual ProsthesisStateBase OnSocketMessage(ProsthesisCore.Messages.ProsthesisMessage message, TCP.ConnectionState state) { return this; }
static Socks.LoginStatus f_OnAuthentication(object sender, TCP.SocksAuthenticationEventArgs e) { if (e.User.Username == "test" && e.User.Password == "test123") return Socks.LoginStatus.Correct; return Socks.LoginStatus.Denied; }
public override void OnClientDataReceived(object sender, TCP.DataEventArgs e) { //throw new NotImplementedException(); }
public override ProsthesisStateBase OnSocketMessage(ProsthesisCore.Messages.ProsthesisMessage message, TCP.ConnectionState state) { ProsthesisStateBase newState = mCurrentState.OnSocketMessage(message, state); if (newState != mCurrentState) { ChangeState(newState); } return this; }
public void loaded() { config = new Data.Config("Config/config.xml"); response = new Dictionary<int, Command>(); userClientList = new Dictionary<User, System.Net.Sockets.TcpClient>(); tr = new Translator(); int serverPort = int.Parse(config["TCP/port"]); network = new TCP(serverPort, "GamePW"); network.OnTextRecieved += new TCP.TextRecievedEvent(TCP_TextRecieved); network.OnClientConnected += new TCP.ClientConnectedEvent(TCP_ClientConnected); network.OnError += new TCP.TCPErrorEvent(TCP_Error); network.OnClientDisconnected += new TCP.ClientDisconnectedEvent(TCP_ClientDisconnected); printStatistics(); log("Server bereit für Anfragen ..."); }
public void main() { try { int serverPort = int.Parse(config["TCP/port"]); network = new TCP(serverPort, "GamePW"); network.OnTextRecieved += new TCP.TextRecievedEvent(TCP_TextRecieved); network.OnClientConnected += new TCP.ClientConnectedEvent(TCP_ClientConnected); network.OnError += new TCP.TCPErrorEvent(TCP_Error); network.OnClientDisconnected += new TCP.ClientDisconnectedEvent(TCP_ClientDisconnected); log("Lade Spiel Daten ... "); string filepath = config["Game/GameDataPath"] + "GameData.dat"; if (!File.Exists(filepath)) { Console.WriteLine("Game Data Datei nicht gefunden!"); close = true; return; } game = new GameData(filepath); log("Spiel Dateien erfolgreich geparsed"); modulmanager = new ModulManager(this); log("Modul Manager erfolgreich gestartet"); printStatistics(); // log("Server bereit für Anfragen ..."); // TestUser User user = new User(1, "test", "4", game.getRace(1)); user.password = "******"; user.encryptPassword(); addUser(user); log("Lade Map-Daten bitte warten..."); modulmanager.map.load(config["Game/Map/File"]); } catch (Exception ex) { log("Fehler: " + ex.Message); close = true; } }
public virtual ProsthesisStateBase OnClientAuthorization(TCP.ConnectionState authedClient, bool isAuthorized) { return this; }
/// <summary> /// 读取数据 /// </summary> public void RequestData(FunctionCode fc, int startAddr, int len) { if (len == 0) return; TCP temp = new TCP(m_config_Modbus.m_DeviceAddress, fc, startAddr, len); SendList.Enqueue(temp); }
public override void OnDataSent(object sender, TCP.DataEventArgs e) { Console.WriteLine(Encoding.ASCII.GetString(e.Buffer, e.Offset, e.Count)); }
/// <summary> /// 后台线程提交数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage == -1) { byte[] sendbuffer = e.UserState as byte[]; Console.WriteLine("TX: " + BitConverter.ToString(sendbuffer, 0).Replace("-", " ")); try { sw = File.AppendText(logfile); sw.WriteLine(DateTime.Now.ToString() + " TX: " + BitConverter.ToString(sendbuffer, 0).Replace("-", " ")); sw.Close(); } catch(Exception ex) { Console.WriteLine(ex.ToString()); } } else if (e.ProgressPercentage > 0) { byte[] receive = new byte[e.ProgressPercentage]; Array.Copy(e.UserState as byte[], receive, e.ProgressPercentage); Console.WriteLine("RX: " + BitConverter.ToString(receive, 0).Replace("-", " ")); try { sw = File.AppendText(logfile); sw.WriteLine(DateTime.Now.ToString() + " RX: " + BitConverter.ToString(receive, 0).Replace("-", " ")); sw.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { byte[] btemp = new byte[2] { receive[5], receive[4] }; int bufferlen = BitConverter.ToInt16(btemp, 0) + 6; if (bufferlen == receive.Length)//报文长度正确 { TCP tcptemp = new TCP(receive, m_len, m_startAddr, dataType); if ((tcptemp.Responseread != null) && (tcptemp.Responseread.ByteNum != 0)) { Console.WriteLine("RX: FC:{0} ", tcptemp.Responseread.FC); try { sw = File.AppendText(logfile); sw.WriteLine(DateTime.Now.ToString() + " RX: FC:{0} ", tcptemp.Responseread.FC); sw.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } var datas = tcptemp.GetData(); foreach (var data in datas) { //if (data.Addr == 0) continue; Console.WriteLine("RX: " + "addr:" + data.Addr.ToString() + " " + "data:" + data.Data.ToString()); try { sw = File.AppendText(logfile); sw.WriteLine("RX: " + "addr:" + data.Addr.ToString() + " " + "data:" + data.Data.ToString()); sw.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } numInf numtemp = new numInf(); if (find.TryGetValue(data.Addr, out numtemp)) { numtemp.val = Convert.ToSingle(data.Data); numtemp.dtm = DateTime.Now; find.Remove(data.Addr); find.Add(data.Addr, numtemp); } else { numtemp.val = Convert.ToSingle(data.Data); numtemp.dtm = DateTime.Now; find.Add(data.Addr, numtemp); } } sendFlag = true; Console.WriteLine("\n"); try { sw = File.AppendText(logfile); sw.WriteLine("\r\n"); sw.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }//end if ((tcptemp.Responseread != null) && (tcptemp.Responseread.ByteNum != 0)) }//end if (bufferlen == buffer.Length) }// end try catch (Exception ex) { Console.WriteLine(ex.ToString()); //System.Diagnostics.Debug.WriteLine(ex.ToString()); } } }
public static Address Proto2Address(TCP.Address addr) { return new Address(addr.Protocol, addr.System, addr.Host, addr.Port); }
public override ProsthesisStateBase OnConnection(TCP.ConnectionState state) { return new AwaitingAuth(mContext); }
public override ProsthesisStateBase OnProsthesisCommand(ProsthesisCore.ProsthesisConstants.ProsthesisCommand command, TCP.ConnectionState from) { switch (command) { case ProsthesisCore.ProsthesisConstants.ProsthesisCommand.Shutdown: return new Shutdown(this); default: { ProsthesisStateBase newState = mCurrentState.OnProsthesisCommand(command, from); if (newState != mCurrentState) { ChangeState(newState); } } break; } return this; }