public SimpleHttpServer(IServerNode handler, IServerLogger logger = null, int flags = 0, string allowOrigin = "") { RequestHandler = handler; Logger = logger; if (Logger == null) { Logger = new ConsoleLogger(); } Flags = flags; AllowOrigin = ""; if ((Flags & RequestContext.FLAG_PUBLIC) != 0) { AllowOrigin = allowOrigin; // normally only public services need this } if (AllowOrigin.Length > 0) { m_HeadersForAllowOrigin.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); m_HeadersForAllowOrigin.Add("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, HEAD, DELETE, CONNECT"); m_HeadersForAllowOrigin.Add("Access-Control-Allow-Origin", AllowOrigin); } if (HttpMessage.JsonCodec == HttpMessage.DefaultJsonCodec) { HttpMessage.JsonCodec = new CommonJsonCodec(); } }
public async Task <string> Unload(IServerNode node) { //System.Diagnostics.Debugger.Break(); await Task.Delay(100); var tables = GetGameTables(); if (tables.Count > 0) { node.GetLogger().Info("Closing " + tables.Count + " game table(s)..."); foreach (var gameTable in tables) { await gameTable.Close(); } node.GetLogger().Info("Done"); } lock (m_GameTables) { m_GameTables.Clear(); } await Task.Delay(100); return(""); }
public TableInfoDeliverer(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_IsRunning = false; }
public MerchantDataCache(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_ServerName = m_Node.GetName(); m_IsRunning = false; }
public BetResultDeliverer(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_ServerName = m_Node.GetName(); m_IsRunning = false; }
public AggregationRunner(IServerNode node, IPluginProgressProvider progress, IServerPluginContext context) { this.Node = node; this.Context = context; this.ProgressProvider = progress; this.ActionLine = GenerateLineString(node); this.ReportBuilder = new StringBuilder(); this.BoardLen = node.Board.Length; }
public TransactionCleaner(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_ServerName = m_Node.GetName(); m_IsWorking = false; m_IsRunning = false; }
public void Execute(IPluginProgressProvider progress) { //If the user selects plugin from the menu we can ask controller about currently selected node. IServerNode currentlySelectedNode = Context.Controller.SelectedNode; if (currentlySelectedNode == null) { MessageBox.Show("There is no node selected at the moment"); return; } // We want to ask for range, ev and equity of a current player to act. // If it is not action node - we will show those values for OOP Player IServerPlayer player; // We can get the action player from currently selected node if (currentlySelectedNode.ActionPlayer != null) { player = currentlySelectedNode.ActionPlayer; } else { // This is the way to get OOP player object from the API player = this.Context.ServerUtils.OOP; } // We will get the weight, ev and equity of the single holding AsQs, // average of all the holding in the AQ+ category // and total for all hands // We can construct a hand object by parsing single hand PioViewerApi.Util.Hand asqs = new Hand("AQss"); // We can also parse range using utility method. Range object is a holder of hand, weight pairs PioViewerApi.Util.IRange aqplus = this.Context.ServerUtils.CreateRange("AQ+"); //We will collect the information in the String Builder object. StringBuilder result = new StringBuilder(); result.AppendLine("Basic report for " + player.Name + " in node " + currentlySelectedNode.NodeId); // This is how you convert a hand to nice looking string, and get the human readable format of a range result.AppendLine("Reporting range, EV and equity for " + asqs.ToUnicodeString() + " and subrange " + aqplus.ToSingleLineString()); // Ask solver for the range of a given player in a node IRange range = this.Context.ServerWrapper.ShowRange(player, currentlySelectedNode); // Ask solver for equity EVRange equity = this.Context.ServerWrapper.CalcEquityInNode(player, currentlySelectedNode); // Ask solver for EV EVRange ev = this.Context.ServerWrapper.CalcEVInNode(player, currentlySelectedNode); ReportRange(result, asqs, aqplus, range); result.AppendLine("Equity:"); ReportEVEquity(result, equity, asqs, aqplus); result.AppendLine("EV:"); ReportEVEquity(result, ev, asqs, aqplus); MessageBox.Show(result.ToString(), "Tutorial 4"); }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); await Task.Delay(50); node.GetLogger().Info(this.GetType().Name + " service started"); await Task.Delay(50); return(""); }
private string GenerateLineString(IServerNode node) { string line = node.NodeText; var parent = node.Parent; while (parent.Parent != null) { line = parent.NodeText + " " + line; parent = parent.Parent; } return(line); }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); m_LocalNode = node; await Task.Delay(50); node.GetLogger().Info(this.GetType().Name + " service loaded - default merchant api service"); return(""); }
/// <summary> /// Get the results from one particular node into the structure /// </summary> public static ReportLine CreateReportLineForNode(IServerNode node, IServerPluginContext context) { var result = new ReportLine(); var OOP = context.ServerUtils.OOP; var IP = context.ServerUtils.IP; //the board result.Board = node.Board; // Calculate IP and OOP ev and equity in the node. // The result for EV calculation is two ranges // one range is sums and the other is matchups // EV for a given hand can be calculated by dividing // sums by matchups. // The total EV in node can be obtained by diving // total sums in the node by total counters var evIP = context.ServerWrapper.CalcEVInNode(IP, node); var evOOP = context.ServerWrapper.CalcEVInNode(OOP, node); result.EVOOPSums = evOOP.TotalWins(); result.EVOOPMatchups = evOOP.TotalMatchups(); result.EVIPSums = evIP.TotalWins(); result.EVIPMatchups = evIP.TotalMatchups(); var eqIP = context.ServerWrapper.CalcEquityInNode(IP, node); var eqOOP = context.ServerWrapper.CalcEquityInNode(OOP, node); result.EQOOPSums = eqOOP.TotalWins(); result.EQOOPMatchups = eqOOP.TotalMatchups(); result.EQIPSums = eqIP.TotalWins(); result.EQIPMatchups = eqIP.TotalMatchups(); // If the node is action node (e.g. - not a street split node nor final node) // then we also compute how often given action is selected if (node.ActionPlayer != null) { // we ask server to list all children of a current node var actions = context.ServerWrapper.ShowChildren(node); foreach (var action in actions) { // for each child we ask for the range of an action player var rangeForAction = context.ServerWrapper.ShowRange(node.ActionPlayer, action); // and store it in the result dictionary // NodeText property denotes the action (e.g. CHECK or BET 100) result.ActionFrequencies[action.NodeText] = rangeForAction.TotalWeights(); // Node name is stored separately to preserve the action's order result.ActionNames.Add(action.NodeText); } } return(result); }
public void JoinWith(IServerNode node) { _node = node; //node.InternalNet.PeerConnectedEvent.Subscribe(OnNodeConnected); _nodesGroup = new Group("MOUSENodes"); _nodesGroup.Trace(true); _nodesGroup.RegisterHandler(CustomBroadcast, (Action <byte[]>)OnBroadcastMessage); _nodesGroup.RegisterHandler(CustomQuery, (Action <byte[]>)OnCustomQuery); _nodesGroup.RegisterViewHandler((ViewHandler)ClusterViewChanged); _nodesGroup.Join(); }
public async Task <string> Unload(IServerNode node) { //System.Diagnostics.Debugger.Break(); //await Task.Delay(100); node.GetLogger().Info(this.GetType().Name + " is unloading..."); await Task.Delay(100); node.GetLogger().Info(this.GetType().Name + " is unloaded"); //await Task.Delay(100); return(""); }
public async Task <string> Unload(IServerNode node) { //System.Diagnostics.Debugger.Break(); await Task.Delay(100); if (m_Updater != null) { m_Updater = null; } await Task.Delay(100); return(""); }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); if (m_Updater == null) { m_Updater = new BetResultUpdater(node); } await Task.Delay(50); node.GetLogger().Info(this.GetType().Name + " service started"); return(""); }
public async Task <string> Unload(IServerNode node) { //System.Diagnostics.Debugger.Break(); await Task.Delay(50); if (m_Clients != null) { m_Clients.Clear(); } m_Clients = null; await Task.Delay(50); return(""); }
public void Execute(IPluginProgressProvider progress) { //If the user selects plugin from the menu we can ask controller about currently selected node. IServerNode currentlySelectedNode = Context.Controller.SelectedNode; //If there is no node selected - the property will be null. if (currentlySelectedNode == null) { MessageBox.Show("There is no node selected at the moment"); } else { MessageBox.Show(currentlySelectedNode.NodeText + " is currently selected"); } }
public BaccaratGame(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_GameState = GAME_STATUS.Unknown; m_WaitingForDealing = false; m_IsRunningGameLoop = false; PlayerPoints = -1; BankerPoints = -1; m_ShoeCode = ""; m_RoundIndex = 0; }
public void Init(string name, uint localId, ActorDescription desc, IServerNode node) { _name = name; _localId = localId; _fullName = string.Format("Actor<Name:{0}, LocalId:{1}, Type:{2}>",name, localId, GetType().Name); _description = desc; Node = node; Log = LogManager.GetLogger(_fullName); Fiber = new ServerFiber(); _handlers = new Dictionary<uint, NetContractHandler>(); foreach (NetContractDescription implementedContract in desc.ImplementedContracts) { _handlers.Add(implementedContract.TypeId, new NetContractHandler(node.Dispatcher, implementedContract.TypeId, this)); } OnCreated(); }
public void Init(string name, uint localId, ActorDescription desc, IServerNode node) { _name = name; _localId = localId; _fullName = string.Format("Actor<Name:{0}, LocalId:{1}, Type:{2}>", name, localId, GetType().Name); _description = desc; Node = node; Log = LogManager.GetLogger(_fullName); Fiber = new ServerFiber(); _handlers = new Dictionary <uint, NetContractHandler>(); foreach (NetContractDescription implementedContract in desc.ImplementedContracts) { _handlers.Add(implementedContract.TypeId, new NetContractHandler(node.Dispatcher, implementedContract.TypeId, this)); } OnCreated(); }
public ClientHolder(IServerNode node) { m_Node = node; m_Logger = m_Node.GetLogger(); m_ServerName = m_Node.GetName(); if (m_Clients != null) { m_Clients.Clear(); } else { m_Clients = new Dictionary <string, ClientInfo>(); } }
public async Task <string> Unload(IServerNode node) { //System.Diagnostics.Debugger.Break(); await Task.Delay(100); if (m_LocalCacheUpdater != null) { m_LocalCacheUpdater.Stop(); m_LocalCacheUpdater = null; } await Task.Delay(100); node.GetLogger().Info(this.GetType().Name + " service stopped"); return(""); }
/// <summary> /// Looks for all the nodes with the same action line, but different board cards. /// </summary> public List <IServerNode> FindSimilarNodesOnOtherBoards(IServerNode node) { Stack <IServerNode> fullPath = new Stack <IServerNode>(); for (IServerNode temp = node; temp.Parent != null; temp = temp.Parent) { fullPath.Push(temp); } List <IServerNode> allSimilar = new List <IServerNode>(); allSimilar.Add(fullPath.Pop()); List <IServerNode> tempList = new List <IServerNode>(); int progressReportingPathIndex = 0; int progressReportingPathTotal = fullPath.Count; while (fullPath.Count > 0) { var pattern = fullPath.Pop(); int progressReportingNodeIndex = 1; progressReportingPathIndex++; foreach (var item in allSimilar) { ProgressProvider.UpdateProgress("listing nodes. Path (" + progressReportingPathIndex + "/" + progressReportingPathTotal + ") " + progressReportingNodeIndex++ + " nodes"); if (ProgressProvider.CancelRequested) { return(new List <IServerNode>()); } var itemChildren = Context.ServerWrapper.ShowChildren(item); foreach (var child in itemChildren) { if (child.NodeText == pattern.NodeText || item.NodeType == "SPLIT_NODE") { tempList.Add(child); } } } allSimilar = tempList; tempList = new List <IServerNode>(); } return(allSimilar); }
public WebSocketServer(IServerNode handler, IServerLogger logger = null, int flags = 0) { RequestHandler = handler; Logger = logger; if (Logger == null) { Logger = new ConsoleLogger(); } Flags = flags; if (WebMessage.JsonCodec == WebMessage.DefaultJsonCodec) { WebMessage.JsonCodec = new CommonJsonCodec(); } }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); if (m_Game == null) { m_Game = new BaccaratGame(node); } node.GetLogger().Info(this.GetType().Name + " is loading settings from config..."); //var lines = m_Game.PlayOneRound(); //foreach (var line in lines) node.GetServerLogger().Info(line); try { ConfigurationManager.RefreshSection("appSettings"); await Task.Delay(100); var keys = ConfigurationManager.AppSettings.Keys; foreach (var key in keys) { if (key.ToString() == "GameTable") { m_Game.TableCode = ConfigurationManager.AppSettings["GameTable"].ToString(); break; } } node.GetLogger().Info("Done"); } catch (Exception ex) { node.GetLogger().Error("Failed to load settings from config for BaccaratGame: "); node.GetLogger().Error(ex.ToString()); } if (m_Game != null) { m_Game.Start(); } await Task.Delay(100); node.GetLogger().Info(this.GetType().Name + " started"); return(""); }
public void Execute(IPluginProgressProvider progress) { //If the user selects plugin from the menu we can ask controller about currently selected node. IServerNode currentlySelectedNode = Context.Controller.SelectedNode; if (currentlySelectedNode == null) { MessageBox.Show("There is no node selected at the moment"); return; } if (currentlySelectedNode.Parent == null) { MessageBox.Show("Selected node has no parent"); return; } this.Context.Controller.SelectedNode = currentlySelectedNode.Parent; }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); m_BaseBetCode = Guid.NewGuid().ToString(); node.GetLogger().Info("Reloading database settings from config..."); await Task.Delay(50); // we can apply new merchant db config just by hot-swapping, no need to restart server node.GetDataHelper().RefreshDatabaseSettings(); await Task.Delay(50); node.GetLogger().Info(this.GetType().Name + " service started"); return(""); }
public HttpServer(IServerNode handler, IServerLogger logger = null, int flags = 0, string allowOrigin = "") { m_TaskSchedulerPair = new ConcurrentExclusiveSchedulerPair(TaskScheduler.Default, ListenerWorkerThreadCount); m_ListenerTaskFactory = new TaskFactory(m_TaskSchedulerPair.ConcurrentScheduler); RequestHandler = handler; Logger = logger; if (Logger == null) { Logger = new ConsoleLogger(); } Flags = flags; if ((Flags & RequestContext.FLAG_PUBLIC) != 0) { AllowOrigin = allowOrigin; // normally only public services need this } }
public async Task <string> Load(IServerNode node) { //System.Diagnostics.Debugger.Break(); if (m_LocalCacheUpdater == null) { m_LocalCacheUpdater = new MerchantDataCache(node); } await Task.Delay(50); if (m_LocalCacheUpdater != null) { await m_LocalCacheUpdater.Start(); } await Task.Delay(50); node.GetLogger().Info(this.GetType().Name + " service started"); return(""); }
public Actor Create(IServerNode node, string name, uint primaryContractId) { Contract.Requires(name != null); Contract.Ensures(Contract.Result <Actor>() != null); ActorDescription desc = GetDescription(primaryContractId); Log.Debug("Creating {0} with name:{1}", desc, name); var actor = (Actor)Activator.CreateInstance(desc.Type); uint localId = (uint)Interlocked.Increment(ref _idCounter); actor.Init(name, localId, desc, node); lock (_fullLock) { _actorsByLocalId.Add(actor.LocalId, actor); } return(actor); }
protected override void Setup() { _node = CreateNode(); _node.Start(); }
public Actor Create(IServerNode node, string name, uint primaryContractId) { Contract.Requires(name != null); Contract.Ensures(Contract.Result<Actor>() != null); ActorDescription desc = GetDescription(primaryContractId); Log.Debug("Creating {0} with name:{1}", desc, name); var actor = (Actor)Activator.CreateInstance(desc.Type); uint localId = (uint)Interlocked.Increment(ref _idCounter); actor.Init(name, localId, desc, node); lock (_fullLock) { _actorsByLocalId.Add(actor.LocalId, actor); } return actor; }