private void FsttHandle4UF(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; }
private void DdelHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; if (tpath.Replace(".", String.Empty) == "") { ErrorMessage(MessageSocket, "Directory does not Exist."); } else { try { if (!Directory.Exists(path)) { ErrorMessage(MessageSocket, "Directory does not Exist."); } else { try { Directory.Delete(path); TextMessage(MessageSocket, ServerControl.TEXT, "Directory Deleted."); } catch { ErrorMessage(MessageSocket, "Can't delete <directory>. Please make sure there is no file under this directory."); } } } catch (Exception e) { CloFunc.Errorinfo("UnExpected DDEL Fail:\n" + e.ToString()); } } }
private void OnStop() { if (consoleMessages) { Console.WriteLine("Stopping Website with ServerControl..."); } if (_runningThreads != null) { ServerControl.UnRegisterBackgroundOperationPreCall(_preCall); ServerControl.UnRegisterBackgroundOperationPostCall(_postCall); } ServerControl.Stop(); if (consoleMessages) { Console.WriteLine("Website stoppped with ServerControl."); } if (pidfile != null) { if (consoleMessages) { Console.WriteLine("Deleting pidfile..."); } new FileInfo(pidfile).Delete(); if (consoleMessages) { Console.WriteLine("Pidfile deleted."); } } _shutdownEvent.Set(); }
private void CdirHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; if (tpath.Replace(".", String.Empty) == "") { ErrorMessage(MessageSocket, "Illegal <directory>"); } else { try { if (Directory.Exists(path)) { ErrorMessage(MessageSocket, "Directory Alread Exists."); } else { Directory.CreateDirectory(path); TextMessage(MessageSocket, ServerControl.TEXT, "Directory Created."); } } catch (Exception e) { CloFunc.Errorinfo("UnExpected CDIR Fail: " + e.ToString()); } } }
private void RpasHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { try { string ThisMessage = ByteEncoding(Message, MessageCount); StreamReader logincp = new StreamReader(Config.userpath);//login check process int tempindex = 0; string stemp = logincp.ReadLine(); string[] temp = stemp.Split(' ');//split string with whitespace. stemp = logincp.ReadLine(); while (stemp != null) { ++tempindex; temp = stemp.Split(' '); if (temp[0] == Dict[Address].username) { break; } stemp = logincp.ReadLine(); } logincp.Close(); string[] Alllines = File.ReadAllLines(Config.userpath); Alllines[tempindex] = Dict[Address].username + ' ' + ThisMessage; File.WriteAllLines(Config.userpath, Alllines); TextMessage(MessageSocket, ServerControl.TEXT, "ResetPassword Success."); } catch { // CloFunc.Errorinfo("Unexpected RPAS Fail."); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); currentPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //监听退出进程 var CurrentPro = Process.GetCurrentProcess(); CurrentPro.EnableRaisingEvents = true; CurrentPro.Exited += new EventHandler(Pro_Exit); mainWind = new MainWin(); //启动必要的线程 servercontrol = new ServerControl(); viewcontrol = new ViewControl(mainWind); servercontrol.StartListenThread(); viewcontrol.StartListenServerThread(); mainWind.FormClosed += new FormClosedEventHandler(FormExit); Application.Run(mainWind); }
public static void Main(string[] args) { Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here // TmxHelper.NewTestSuite("name", "id", null, null, null, null); // // // TmxHelper.AddTestScenario( // new AddScenarioCmdletBase { // // new AddTmxTestScenarioCommand { // Name = "name 2", // Id = "id 2", // TestPlatformId = null, // TestSuiteId = null, // Description = null // }); // Tmx.Server.ServerControl.Start(@"http://localhost:12340"); ServerControl.Start("localhost", 12340); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public new void Stop() { Logger.Info(@"Rank server stopping..."); ServerControl.Stop(); base.Stop(); }
private void ByteMessage(Socket MessageSocket, ServerControl Control, byte[] Message) { byte[] textbuffer = new byte[1 + Message.Length]; textbuffer[0] = (byte)Control; Message.CopyTo(textbuffer, 1); MessageSocket.Send(textbuffer); }
public IEnumerator WaitForServer(float _waitTime) { yield return(new WaitForSeconds(_waitTime)); while (true) { if (socketFlag == true) { socketFlag = false; if (ServerControl.SendCreatureList()) { StartCoroutine(ServerControl.ListenForHostileCreatureList(3.0f)); } else { NetworkErrorPanelactive(); } break; } } while (true) { if (creatureFlag == true) { creatureFlag = false; break; } } }
//Save parameters stored in the button to the PublicLevel and load scene public override void InitLevel() { StartCoroutine(ServerControl.OpenStream(3.0f)); PublicLevel.SetLevel(hostileType, manaAmount, manaRegenTime, creatureSpawnTime, stageLevel, false, null); WaitForServer(3.0f); }
private void DlflHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; if (tpath.Split('\\').ToArray().Length > 1) { ErrorMessage(MessageSocket, "Do not contain directory in <file>."); } else { try { if (!File.Exists(path)) { ErrorMessage(MessageSocket, "File does not Exist."); } else { try { TextMessage(MessageSocket, ServerControl.DLFL, tpath); Dict[Address].ThreadState.Download = true; } catch { ErrorMessage(MessageSocket, "Unexpected Error."); } } } catch (Exception e) { CloFunc.Errorinfo("UnExpected DLFL Fail:\n" + e.ToString()); } } }
private void FdelHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; if (tpath.Split('\\').ToArray().Length > 1) { ErrorMessage(MessageSocket, "Do not contain directory in <file>."); } else { try { if (!File.Exists(path)) { ErrorMessage(MessageSocket, "File does not Exist."); } else { try { File.Delete(path); TextMessage(MessageSocket, ServerControl.TEXT, "File Deleted."); } catch { ErrorMessage(MessageSocket, "Can't delete <File>. Please make sure it's not occupied."); } } } catch (Exception e) { CloFunc.Errorinfo("UnExpected FDEL Fail:\n" + e.ToString()); } } }
public new void Stop() { Logger.Info(@"Scene server stopping..."); PathManager.Stop(); ServerControl.Stop(); base.Stop(); }
public MainWindow(ClientControl clientControl, ServerControl serverControl) { InitializeComponent(); DataContext = _viewModel; ClientContentControl.Content = clientControl; ServerContentControl.Content = serverControl; }
public MainWindow() { IServerControl serverControl = new ServerControl(); InitializeComponent(); //ContentControl.DataContext = serverControl; ContentControl.Content = serverControl; }
private void TextMessage(Socket MessageSocket, ServerControl Control, string Message) { //these code is based on "ErrorMessage" function byte[] text = System.Text.Encoding.Default.GetBytes(Message); byte[] textbuffer = new byte[1 + text.Length]; textbuffer[0] = (byte)Control; text.CopyTo(textbuffer, 1); MessageSocket.Send(textbuffer); }
private void FsttHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { string path = ByteEncoding(Message, MessageCount); string tpath = path; path = Config.filepath + @"\" + Dict[Address].filepath + @"\" + path; if (tpath.Split('\\').ToArray().Length > 1) { ErrorMessage(MessageSocket, "Do not contain directory in <file>."); } else { try { if (!File.Exists(path)) { ErrorMessage(MessageSocket, "File does not Exist."); } else { try { FileStream fp = new FileStream(path, FileMode.Open, FileAccess.Read);//, FileShare.Read); byte[] messagebuff = new byte[2047]; TextMessage(MessageSocket, ServerControl.FSTT, fp.Length.ToString()); long count = (fp.Length + 2046) / 2047; byte[] finalmessage = new byte[(int)(fp.Length % 2047)]; for (long i = 0; i < count; ++i) { if (i + 1 != count) { fp.Read(messagebuff, 0, 2047); ByteMessage(MessageSocket, ServerControl.FILE, messagebuff); } else { fp.Read(finalmessage, 0, finalmessage.Length); ByteMessage(MessageSocket, ServerControl.FEND, finalmessage); } } /////////ByteMessage & TextMessage may be cat by Socket or FTP/////// /////////cause an unrepairable bug /////////so add an [meaningless] operation here to avoid bug log(Address + " < " + path + " Download Over."); //////////////////////////////////////// //TextMessage(MessageSocket, ServerControl.FEND, "DL END"); Dict[Address].ThreadState.Download = false; fp.Close(); } catch { ErrorMessage(MessageSocket, "Unexpected Error."); } } } catch (Exception e) { CloFunc.Errorinfo("UnExpected FSTT Fail:\n" + e.ToString()); } } }
public void Start() { Logger.Info(@"Scene server starting..."); PathManager.Start(); SceneManager.Instance.Init(); //TestFight.Test(); ServerControl.Start(mPort, mAuth, Logger); }
private void FileHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { try { Dict[Address].fp.Write(Message, 1, MessageCount); } catch { CloFunc.Errorinfo("Unexpected FILE Fail."); } }
private void FendHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { try { Dict[Address].fp.Write(Message, 1, MessageCount); log(Address + " > " + Dict[Address].fp.Name + " Upload Over."); Dict[Address].fp.Close(); Dict[Address].ThreadState.Upload = false; } catch { CloFunc.Errorinfo("Unexpected FILE Fail."); } }
public void WritesServerControl(bool canBlockReload, double?canSkipUntil, double?holdBack, double?partHoldBack, string expected) { var serverControl = new ServerControl { CanBlockReload = canBlockReload, CanSkipUntil = canSkipUntil, HoldBack = holdBack, PartHoldBack = partHoldBack }; AssertStreamContentEqual(expected, serverControl); }
public static void Main(string[] args) { try { ServerControl.Port = 12340; ServerControl.Start(@"http://*****:*****@"Press any key to stop server . . . "); Console.ReadKey(true); ServerControl.Stop(); /* * try * { * ServerControl.Start(TestSettings.BaseUrl); * * if (!Environment.UserInteractive) * { * var services = new ServiceBase[] { new ServiceControl() }; * ServiceBase.Run(services); * } * else * { * var service = new ServiceControl(); * Thread.Sleep(Timeout.Infinite); * } * } * catch (Exception ex) * { * Console.WriteLine(ex.Message); * Console.WriteLine(ex.StackTrace); * // Console.WriteLine(ex.InnerException.Message); * } * Console.Write("Press any key to stop server . . . "); * Console.ReadKey(true); * ServerControl.Stop(); */ }
public new void Status(ConcurrentDictionary <string, string> dict) { try { if (ServerControl != null) { ServerControl.Status(dict); } } catch { // ... } }
private bool AuthorityCheck(ServerControl Control, UserGroup usergroup) { if (usergroup == UserGroup.Root) { return(true); } else if (usergroup == UserGroup.Stranger) { ServerControl[] A = { ServerControl.USER, ServerControl.PASS, ServerControl.BYTE, ServerControl.BEND }; return(-1 != Array.IndexOf(A, Control));//if "control" is not in "A" , then "indexof" will return -1. } else if (usergroup == UserGroup.Guest) { ServerControl[] A = { ServerControl.USER, ServerControl.PASS, ServerControl.DBUG, ServerControl.CDCD, ServerControl.LIST }; return(-1 != Array.IndexOf(A, Control)); } else if (usergroup == UserGroup.General) { ServerControl[] A = { ServerControl.USER, ServerControl.PASS, ServerControl.DBUG, ServerControl.DLFL, ServerControl.ULFL, ServerControl.FSTT, ServerControl.FILE, ServerControl.FEND, ServerControl.CDCD, ServerControl.LIST, ServerControl.RPAS }; return(-1 != Array.IndexOf(A, Control)); } return(false); }
private void ListHandle(Socket MessageSocket, ServerControl Control, byte[] Message, IPAddress Address) { DirectoryInfo info = new DirectoryInfo(Config.filepath + @"\" + Dict[Address].filepath); DirectoryInfo[] infolist = info.GetDirectories(); FileInfo[] Finfolist = info.GetFiles(); string infoMessage = ""; //add dir info for (int i = 0; i < infolist.Length; ++i) { infoMessage += infolist[i].Name; if (i + 1 != infolist.Length) { infoMessage += "\t"; } } //add file info for (int i = 0; i < Finfolist.Length; ++i) { if (i == 0 && infolist.Length == 0) { infoMessage += Finfolist[i].Name; } else { infoMessage += "\t" + Finfolist[i].Name; } } byte[] listMessage = Encoding.Default.GetBytes(infoMessage); int count = (listMessage.Length + (2048 - 2)) / (2048 - 1);//ceil byte[] smessage; for (int i = 0; i < count; ++i) { if (i + 1 != count) { smessage = listMessage.Take(2047).ToArray(); listMessage = listMessage.Skip(2047).ToArray(); } else { smessage = listMessage; } ByteMessage(MessageSocket, ServerControl.LIST, smessage); } ///may crash. TextMessage(MessageSocket, ServerControl.LEND, "OVER."); }
protected override void OnStartup(StartupEventArgs e) { var ipAddress = ConfigurationManager.AppSettings["ipaddress"]; var port = int.Parse(ConfigurationManager.AppSettings["port"]); var clientControl = new ClientControl(new TheClient(ipAddress, port), new ClientControlViewModel { IpAddress = ipAddress, Port = port }); var serverControl = new ServerControl(new Server(ipAddress, port), new ServerControlViewModel { IpAddress = ipAddress, Port = port }); var mainWindow = new MainWindow(clientControl, serverControl); MainWindow.ShowDialog(); }
public static void CreateServerList() { var _Margin = new System.Windows.Thickness(15, 5, 15, 0); foreach (Server s in References.serverCollection.Servers) { ServerControl serverControl = Application.Current.Dispatcher.Invoke(() => new ServerControl()); serverControl.Dispatcher.Invoke(() => serverControl.Flag.Source = GetFlag(s)); serverControl.Dispatcher.Invoke(() => { serverControl.Margin = _Margin; }); serverControl.Dispatcher.Invoke(() => { serverControl.Server = s; }); serverControl.Dispatcher.Invoke(() => { serverControl.ServerNameLabel.Content = s.Name; }); serverControl.Dispatcher.Invoke(() => { serverControl.Visibility = Visibility.Hidden; }); MainWindow.Instance.ServerStackPanel.Dispatcher.Invoke(() => MainWindow.Instance.ServerStackPanel.Children.Add(serverControl)); } RefreshInteface(); }
private void ByteHandle(Socket MessageSocket, ServerControl Control, byte[] Message, int MessageCount, IPAddress Address) { try { if (Dict[Address].ThreadState.transmission) { Dict[Address].ByteBuff = CloFunc.Bytecat(Dict[Address].ByteBuff, Message.Skip(1).ToArray()); } else { Dict[Address].ThreadState.transmission = true; Dict[Address].ByteBuff = Message.Skip(1).ToArray(); } } catch { //CloFunc.Errorinfo("Unexpected Byte Fail."); } }
private void ServerControl_Close(object sender, EventArgs e) { ServerControl serverControl = (ServerControl)sender; ServerControlDataContext dataContext = (ServerControlDataContext)serverControl.DataContext; for (int i = 0; i < ServerForms.Items.Count; i++) { TabItem currentTab = (TabItem)ServerForms.Items[i]; ServerControl currentServerControl = currentTab.Content as ServerControl; if (currentServerControl == null || currentServerControl.DataContext != dataContext) { continue; } ServerForms.Items.RemoveAt(i); break; } }
void Start() { // if (!BrainCloudWrapper.GetBC ().IsAuthenticated()) { // Application.LoadLevel("Login"); } // else { UpdateScoreText(); // ReadStatistics(); } serverControl = new ServerControl (); }
/// <summary> /// /// </summary> void Awake() { Instance = this; }
// Use this for initialization void Start() { m_username = PlayerPrefs.GetString("username"); serverControl = new ServerControl (); // Stores the password in plain text directly in the unity store. // This is obviously not secure but speeds up debugging/testing. // m_password = PlayerPrefs.GetString("password"); }