public static BoardCoordinatesViewModel CreateConnectedViewModel(ConnectionProxy connectionProxy, Player mainPlayer, Enemy mainEnemy, Board currboard) { board = currboard; BoardCoordinatesViewModel viewModel = new BoardCoordinatesViewModel(connectionProxy, mainPlayer, mainEnemy); return(viewModel); }
private void cbProxyServers_SelectedIndexChanged(object sender, EventArgs e) { try { string proxyServer = cbProxyServers.SelectedItem.ToString().TrimEnd('/'); if (!proxyServer.Contains("127.0.0.1")) { ConnectionProxy.SetConnectionProxy(proxyServer); } else { ConnectionProxy.RestoreSystemProxy(); } if (wbWhatIsMyIP.Document != null) { wbWhatIsMyIP.Document.Cookie = null; } wbWhatIsMyIP.Navigate("http://www.infobyip.com/detectproxy.php"); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public override void Display(ConnectionProxy chatService) { Random randNum = new Random(); int Randx = randNum.Next(0, 20); int Randy = randNum.Next(0, 20); //MessageBox.Show(Randx + " " + Randy); // chatService.SendMessage("Light hole", 1, this.color, MessageType.lightHole, Randx, Randy); }
public Bonus(ConnectionProxy chatService) { _chatService = chatService; ColorOptions.Add(YellowColorShades.Light, new LightYellowColor()); ColorOptions.Add(YellowColorShades.Dark, new DarkYellowColor()); ColorOptions.Add(YellowColorShades.Normal, new YellowColor()); }
public void Run(ConnectionProxy chatService) { _chatService = chatService; string hiddenColor = Hide(); MessageType type = GetType(); Create(hiddenColor, type); }
private void SpeedTest(ConnectionProxy connectionProxy) { System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); System.Diagnostics.Stopwatch stopwatch2 = new System.Diagnostics.Stopwatch(); stopwatch.Start(); NeutralTileFactory factory = new NeutralTileFactory(); for (int i = 0; i < 10000000; i++) { AbstractNeutralTile tile = factory.GetNeutralTile("Darkest"); tile.Display(connectionProxy); } stopwatch.Stop(); stopwatch2.Start(); for (int i = 0; i < 10000000; i++) { LightestNeutralTile a = new LightestNeutralTile(); a.Display(connectionProxy); } stopwatch2.Stop(); MessageBox.Show("Time taken for 10000000 - using flyweight: " + stopwatch.Elapsed + ", regular: " + stopwatch2.Elapsed); stopwatch.Reset(); stopwatch2.Reset(); stopwatch.Start(); for (int i = 0; i < 100000000; i++) { AbstractNeutralTile tile = factory.GetNeutralTile("Darkest"); tile.Display(connectionProxy); } stopwatch.Stop(); stopwatch2.Start(); for (int i = 0; i < 100000000; i++) { LightestNeutralTile a = new LightestNeutralTile(); a.Display(connectionProxy); } stopwatch2.Stop(); MessageBox.Show("Time taken for 100000000 - using flyweight: " + stopwatch.Elapsed + ", regular: " + stopwatch2.Elapsed); //for (int i = 0; i < 10; i++) //{ // AbstractNeutralTile tile = factory.GetNeutralTile("Lightest"); // tile.Display(connectionProxy); //} }
public Facade(ConnectionProxy connectionProxy) { _chatService = connectionProxy; _paintBomb = new PaintBombFactory(); _freeze = new FreezeFactory(); _blackSplash = new BlackSplash(_chatService); _freezeYourself = new FreezeYourself(_chatService); _colorSplash = new ColorSplash(_chatService); _freezeOthers = new FreezeOthers(_chatService); _factory = new BonusFactory(); }
void Clear() { if (cp != null) { cp.onCloseEvent = null; cp.onConnectErrorEvent = null; cp.onConnectEvent = null; cp.onReceiveEvent = null; cp.encodeFunc = null; cp.decodeFunc = null; cp.Close(); cp = null; } }
private void SetupSlashCommands() { mJSDispatcher = new JSDispatcher(); mSlashCommands.Add("/jsc", delegate() { mJSDispatcher.ToggleJSConsole(); }); // Only do this in dev ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>(); if (connectionProxy.StageName != "DEV") { return; } mSlashCommands.Add("/newRoom", delegate() { GameFacade.Instance.SendNotification(GameFacade.ENTER_ROOM_CREATOR); }); mSlashCommands.Add("/fashionGame", delegate() { GameFacade.Instance.SendNotification(GameFacade.ENTER_FASHION_MINIGAME); }); mSlashCommands.Add("/roomAPI", delegate() { GameFacade.Instance.SendNotification(GameFacade.SHOW_SERVER_ROOM_API); }); mSlashCommands.Add("/roomPicker", delegate() { GameFacade.Instance.SendNotification(GameFacade.SHOW_ROOM_PICKER_GUI, MessageSubType.ClientOwnedRooms); }); mSlashCommands.Add("/openInventory", delegate() { GameFacade.Instance.RetrieveProxy <InventoryProxy>().OpenPlayerInventory(); }); mSlashCommands.Add("/openShop", delegate() { GameFacade.Instance.SendNotification(GameFacade.SHOP_BUTTON_CLICKED); }); mSlashCommands.Add("/showFriends", delegate() { GameFacade.Instance.SendNotification(GameFacade.SHOW_FRIENDS); }); }
public GridView() { InitializeComponent(); //AddTiles(); //HubConnection connection = new HubConnectionBuilder() // .WithUrl("https://margesignalr20201107074704.azurewebsites.net/margechat") // .Build(); ConnectionProxy chatService = new ConnectionProxy(); chatService.AddMessageReceiver(ChatService_CoordinatesMessageReceived); }
public override Bonus CreateBonus(int bonusId, ConnectionProxy chatService) { switch (bonusId) { case 1: return(new JackPot(chatService)); case 2: return(new Joke(chatService)); default: return(new Normal(chatService)); } }
public override async void Operation(int xa, int ya, ConnectionProxy _chatService) { //Random randNum = new Random(); //PosX = randNum.Next(0, 20); //PosY = randNum.Next(0, 20); //await _chatService.SendCoordinatesMessage(new BoardCoordinates() //{ // messageType = MessageType.enemy, // message = "enemy", // color = "255 0 0", // x = PosX, // y = PosY //}); }
protected override void Awake() { try { base.Awake(); // Application settings go here Application.runInBackground = true; Application.targetFrameRate = 60; // Set up required components, and just the bare minimum of MVC actors. We don't have config data yet, so // anything that requires real data off the network should be registered in StartupCommand or later mGuiManager = new RuntimeGuiManager(mLogger); mLogger.AddReporter(new DebugLogReporter()); mGameFacade = GameFacade.Instance; // Nulls out the reference on application exit for editor integration // Register Required Mediators GameFacade.Instance.RegisterMediator(new LoggerMediator(mLogger)); GameFacade.Instance.RegisterMediator(new InputManagerMediator()); GameFacade.Instance.RegisterMediator(new SchedulerMediator(this.Scheduler)); GameFacade.Instance.RegisterMediator((IMediator)mGuiManager); RuntimeConsole runtimeConsole = new RuntimeConsole(mGuiManager); runtimeConsole.AddCommand("showTasks", ((Scheduler)this.Scheduler).ShowTasks); ((Scheduler)this.Scheduler).Logger = mLogger; GameFacade.Instance.RegisterMediator(runtimeConsole); mLogger.AddReporter(runtimeConsole); mLogger.Log("SceneInit.Awake", LogLevel.Info); ConnectionProxy connectionProxy = new ConnectionProxy(); GameFacade.Instance.RegisterProxy(connectionProxy); // Get configuration data before doing anything else. This sends STARTUP_COMMAND when done getting the config data ConfigManagerClient configManager = new ConfigManagerClient(); GameFacade.Instance.RegisterProxy(configManager); configManager.InitAndStartup(); } catch (System.Exception ex) { // Catch all here is to avoid browser crashes on exit if something becomes unstable. mLogger.Log(ex.ToString(), LogLevel.Error); } finally { mLogger.Flush(); } }
protected override void OnStartup(StartupEventArgs e) { //HubConnection connection = new HubConnectionBuilder() // .WithUrl("https://margesignalr20201107074704.azurewebsites.net/margechat") // .Build(); ConnectionProxy connectionProxy = new ConnectionProxy(); var player = new PlayerBuilder(); player.BuildPlayerName(); player.BuildPlayerColor(); player.BuildPlayerPos(); var enemy = new EnemyBuilder(); enemy.BuildPlayerName(); enemy.BuildPlayerColor(); enemy.BuildPlayerPos(); enemy.passConnection(connectionProxy); var darkenBoard = new Darken(); Board board = new Board(darkenBoard); BoardCoordinatesViewModel chatViewModel = BoardCoordinatesViewModel.CreateConnectedViewModel(connectionProxy, player.GetPlayer(), enemy.GetEnemy(), board); MainWindow window = new MainWindow { DataContext = new MainViewModel(chatViewModel, board) }; window.Show(); NeutralTileFactory factory = new NeutralTileFactory(); for (int i = 0; i < 5; i++) { AbstractNeutralTile tile = factory.GetNeutralTile("Darkest"); tile.Display(connectionProxy); } for (int i = 0; i < 5; i++) { AbstractNeutralTile tile = factory.GetNeutralTile("Lightest"); tile.Display(connectionProxy); } }
public void Connect(string[] host, int port) { Clear(); cp = new ConnectionProxy(); int index = 0; cp.onCloseEvent += () => { eventQueue.Add(NetEventType.CLOSE); }; cp.onConnectErrorEvent += () => { index++; if (index < host.Length) { cp.Connect(host[index], port); } else { eventQueue.Add(NetEventType.CONNECT_ERROR); } }; cp.onConnectEvent += () => { eventQueue.Add(NetEventType.CONNECT); }; cp.onReceiveEvent += (Packet p) => { { packetQueue.Add(p); } }; cp.Connect(host[index], port); }
public void SendSteppedOnBlackSplash(ConnectionProxy _chatService, int xP, int yP) { _chatService.SendMessage("debuff effect", 1, "0 0 0", MessageType.stepedOnBlackSplash, xP, yP); }
public override Debuff CreateDebuff(ConnectionProxy chatService) { return(new BlackSplash(chatService)); }
public override Buff CreateBuff(ConnectionProxy chatService) { return(new ColorSplash(chatService)); }
public abstract void Display(ConnectionProxy chatService);
public JackPot(ConnectionProxy chatService) : base(chatService) { }
public override void Operation(int x, int y, ConnectionProxy _chatService) { _chatService.SendMessage("Steal points ability", 1, "255 0 0", MessageType.stealPointEnemy, x, y); enemy.Operation(x, y, _chatService); }
public void passConnection(ConnectionProxy chatService) { _enemy._chatService = chatService; }
public Renderer() { try { InitializeComponent(); /**/ //remove limits from service point manager ServicePointManager.MaxServicePoints = 10000; ServicePointManager.DefaultConnectionLimit = 10000; ServicePointManager.CheckCertificateRevocationList = true; ServicePointManager.Expect100Continue = false; ServicePointManager.MaxServicePointIdleTime = 1000 * 30; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; ServicePointManager.UseNagleAlgorithm = false; //Use if you encounter certificate errors... ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); /**/ ApplicationSettings applicationSettings = new ApplicationSettings(); _arachnodeDAO = new ArachnodeDAO(applicationSettings.ConnectionString); _htmlRenderer = new HtmlRenderer(_arachnodeDAO); Closed += Renderer_Closed; if (_useAxWebBrowser && !DesignMode) { object o = axWebBrowser1.GetOcx(); IOleObject oleObject = o as IOleObject; oleObject.SetClientSite(this); } axWebBrowser1.Silent = true; if (_useAxWebBrowser) { Thread thread = new Thread(() => { while (true) { Thread.Sleep(1000 * 60 * 1); if (_stopwatch.Elapsed.TotalMinutes > 1) { _stopwatch.Reset(); _stopwatch.Start(); axWebBrowser1.Stop(); axWebBrowser1_DocumentComplete(this, null); } } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } /**/ //uncomment these to use... //_rendererActions.Add(new IFrames()); //_rendererActions.Add(new Hrefs()); //_rendererActions.Add(new Inputs()); _htmlRenderer.DocumentComplete += _htmlParser_DocumentComplete; /**/ if (_debugSingleAbsoluteUri || _debugMultipleAbsoluteUris) { return; } /**/ #region Default Crawling Thread //both should be set to 'false' for default crawling execution... if (!_debugSingleAbsoluteUri && !_debugMultipleAbsoluteUris) { _stopwatchTotal.Reset(); _stopwatchTotal.Start(); _thread = new Thread(delegate() { try { MessageQueue rendererMessageQueue = new MessageQueue(".\\private$\\Renderer_Renderers:" + 0); rendererMessageQueue.Formatter = new XmlMessageFormatter(new[] { typeof(RendererMessage) }); while (rendererMessageQueue.Peek() == null) { Thread.Sleep(10); } Message message = rendererMessageQueue.Receive(); _rendererMessage = (RendererMessage)message.Body; /**/ rendererMessageQueue = new MessageQueue(".\\private$\\Renderer_Renderers:" + _rendererMessage.ThreadNumber); rendererMessageQueue.Formatter = new XmlMessageFormatter(new[] { typeof(RendererMessage) }); _engineMessageQueue = new MessageQueue(".\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber); /**/ //remoting code for Marshalling the HTMLDocumentClass... BinaryClientFormatterSinkProvider clientProvider = null; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; Hashtable props = new Hashtable(); props["name"] = "Renderer" + _rendererMessage.ThreadNumber; props["portName"] = "Renderer" + _rendererMessage.ThreadNumber; props["authorizedGroup"] = WindowsIdentity.GetCurrent().Name; //props["typeFilterLevel"] = TypeFilterLevel.Full; IpcChannel channel = new IpcChannel(props, clientProvider, serverProvider); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(Renderer), "Renderer" + _rendererMessage.ThreadNumber, WellKnownObjectMode.SingleCall); RemotingServices.Marshal(this, "Renderer" + _rendererMessage.ThreadNumber); /**/ tsslStatus.Text = ".\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber + " Awaiting CrawlRequests..."; while (true && !_abortThread) { try { message = rendererMessageQueue.Receive(); _stopwatch.Reset(); _stopwatch.Start(); _rendererMessage = (RendererMessage)message.Body; _htmlRenderer.CrawlRequestTimeoutInMinutes = _rendererMessage.CrawlRequestTimeoutInMinutes; tsslStatus.Text = DateTime.Now.ToLongTimeString() + " .\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber + " " + _rendererMessage.AbsoluteUri + " TimeTakenToReceiveMessage: " + _stopwatch.Elapsed.TotalSeconds; if (!_rendererMessage.Kill) { switch (_rendererMessage.RenderAction) { case RenderAction.Render: if (!string.IsNullOrEmpty(_rendererMessage.ProxyServer)) { ConnectionProxy.SetConnectionProxy(_rendererMessage.ProxyServer.TrimEnd('/')); } else { ConnectionProxy.RestoreSystemProxy(); } if (!string.IsNullOrEmpty(_rendererMessage.Cookie)) { //key1=value1;key2=value2; if (!string.IsNullOrEmpty(_rendererMessage.Cookie)) { string[] cookieSplit = _rendererMessage.Cookie.Split(";".ToCharArray()); foreach (string cookieSplit2 in cookieSplit) { string[] cookieSplit3 = cookieSplit2.Split("=".ToCharArray()); if (cookieSplit3.Length >= 2) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 1; i < cookieSplit3.Length; i++) { stringBuilder.Append(cookieSplit3[i] + "="); } string value = stringBuilder.ToString().TrimEnd("=".ToCharArray()); InternetSetCookie(_rendererMessage.AbsoluteUri, cookieSplit3[0], cookieSplit3[1]); } } } } if (_useAxWebBrowser) { object userAgent = "User-Agent: " + _rendererMessage.UserAgent; object o1 = null; object o2 = null; object o3 = null; DateTime startTime = DateTime.Now; axWebBrowser1.Navigate(_rendererMessage.AbsoluteUri, ref o1, ref o2, ref o3, ref userAgent); if (_modifyDOM) { bool wasDOMModified = false; while (axWebBrowser1.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE && DateTime.Now.Subtract(startTime).Duration().TotalMinutes < _rendererMessage.CrawlRequestTimeoutInMinutes) { Thread.Sleep(100); if (axWebBrowser1.ReadyState == tagREADYSTATE.READYSTATE_INTERACTIVE) { if (!wasDOMModified) { _htmlRenderer.ModifyDOM((IHTMLDocument2)axWebBrowser1.Document, false); wasDOMModified = true; } } } } } else { _htmlRenderer.Render(_rendererMessage.AbsoluteUri); } break; case RenderAction.Back: axWebBrowser1.GoBack(); break; case RenderAction.Forward: axWebBrowser1.GoForward(); break; } try { foreach (Process process in Process.GetProcesses()) { if (process.ProcessName.ToLowerInvariant() == "iexplore" || process.ProcessName.ToLowerInvariant() == "chrome" || process.ProcessName.ToLowerInvariant() == "vsjitdebugger" || process.MainWindowTitle.ToLowerInvariant() == "web browser" || process.MainWindowTitle.ToLowerInvariant() == "renderer" || process.MainWindowTitle.ToLowerInvariant() == "visual studio just-in-time debugger") { //if (MessageBox.Show("Close? 1", "Arachnode.Renderer", MessageBoxButtons.YesNo) == DialogResult.Yes) //{ // process.Kill(); //} } } IntPtr window = WinApis.FindWindowByCaption(IntPtr.Zero, "Web Browser"); if (window != IntPtr.Zero) { WinApis.CloseWindow(window); } window = WinApis.FindWindowByCaption(IntPtr.Zero, "Message from webpage"); if (window != IntPtr.Zero) { WinApis.CloseWindow(window); } } catch (Exception exception) { //MessageBox.Show(exception.Message); //MessageBox.Show(exception.StackTrace); _arachnodeDAO.InsertException(null, null, exception, false); } } else { //if (MessageBox.Show("Close? 2", "Arachnode.Renderer", MessageBoxButtons.YesNo) == DialogResult.Yes) //{ // Process.GetCurrentProcess().Kill(); //} } } catch (Exception exception) { //MessageBox.Show(exception.Message); //MessageBox.Show(exception.StackTrace); _arachnodeDAO.InsertException(null, null, exception, false); } } } catch (Exception exception) { //MessageBox.Show(exception.Message); //MessageBox.Show(exception.StackTrace); _arachnodeDAO.InsertException(null, null, exception, false); } });
public MoveUpChatMessageCommand(BoardCoordinatesViewModel viewModel, ConnectionProxy chatService, Player player) { _viewModel = viewModel; _chatService = chatService; CurrentPlayer = player; }
public void SendSteppedOnColorSplash(ConnectionProxy _chatService, int xP, int yP) { _chatService.SendMessage("buff effect", 1, Color, MessageType.stepedOnColorSplash, xP, yP); }
public override Buff CreateBuff(ConnectionProxy chatService) { return(new FreezeOthers(chatService)); }
public abstract Bonus CreateBonus(int bonusId, ConnectionProxy chatService);
public override Debuff CreateDebuff(ConnectionProxy chatService) { return(new FreezeYourself(chatService)); }
public Joke(ConnectionProxy chatService) : base(chatService) { }
public void SendGameOverMessage(ConnectionProxy _chatService, int currenPlayerId) { _chatService.SendMessage("Game over", currenPlayerId, "255 0 0", MessageType.gameOver, 0, 0); }