public EchoSendHandler(Node n, ISender dest, object req_state) { _rrman = n.Rrm; _rpc = n.Rpc; _req_state = req_state; _dest = dest; }
public override void OnSetInfected() { base.OnSetInfected(); if (NumJesters == 0 || !CheepsAmongUsMod.CheepsAmongUsMod.IsDecidingClient) { return; } var available = PlayerController.AllPlayerControls.Where(x => !x.PlayerData.IsImpostor && !RoleManager.HasPlayerAnyRole(x)).ToList(); for (int i = 0; i < NumJesters; i++) { if (available.Count > 0) { var player = available[Random.Next(available.Count)]; if (RoleManager.HasPlayerAnyRole(player)) { i--; continue; } available.Remove(player); RpcManager.SendRpc(TheJester.JesterRpc, new byte[] { (byte)TheJester.CustomRpc.SetJester, player.PlayerId }); setJester(player); } } }
/** <summary>Creates an Information object for the node and type of service provider.</summary> <param name="node">The node where the service is to be provided</param> <param name="type">The name of the application providing service (example: BasicNode)</param> */ public Information(StructuredNode node, String type) { UserData = new Hashtable(); _type = type; _node = node; _rpc = node.Rpc; _rpc.AddHandler("Information", this); }
static void TraceRoute(IList nodes) { Random my_r = new Random(); int idx0 = my_r.Next(0, nodes.Count); int idx1 = my_r.Next(0, nodes.Count); Node n0 = (Node)nodes[idx0]; Node n1 = (Node)nodes[idx1]; RpcManager pinger = n0.Rpc; Channel results = new Channel(); Console.WriteLine("Traceroute: {0} -> {1}", n0.Address, n1.Address); results.EnqueueEvent += delegate(object q, EventArgs a) { object result = results.Dequeue(); RpcResult r = (RpcResult)result; IList data = (IList)r.Result; int hop = 0; foreach (IDictionary d in data) { Console.WriteLine("Hop: {0} :: {1}\n :: {2}", hop, d["node"], d["next_con"]); hop++; } }; try { pinger.Invoke(n0, results, "trace.GetRouteTo", n1.Address.ToString()); } catch (Exception x) { Console.WriteLine("Exception: {0}", x); } }
public override void Setup() { RpcManager.Init(); listener.Prefixes.Add(Prefix); // Must add prefixes listener.Start(); Start(); }
/** * Compute candidate scores for a shortcut connection. * @param start address computed by the SCO. * @param range nunber of candidate nodes. * @param cb callback function when candidate scores are available. * @param current current selection of the optimal in the provided range. */ public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate cb, Address current) { Channel q = null; RequestState rs = null; lock (_sync) { #if VTS_DEBUG Console.Error.WriteLine("VTS local: {0}, start: {1}, range: {2}, count: {3}", _node.Address, start, range, _num_requests); #endif if (_num_requests == MAX_REQUESTS) { return; //do nothing and return; } _num_requests++; q = new Channel(); rs = new RequestState(start, range, cb, current); _channel_to_state[q] = rs; } //create a new request state ISender s = new ForwardingSender(_node, start, AHHeader.Options.Greedy, new DirectionalAddress(DirectionalAddress.Direction.Left), (short)range, AHHeader.Options.Path ); q.EnqueueEvent += new EventHandler(EnqueueHandler); q.CloseEvent += new EventHandler(CloseHandler); RpcManager rpc = _node.Rpc; rpc.Invoke(s, q, "ncserver.EchoVivaldiState", new object[] {}); }
public static bool Prefix() { if (!Cleaner.GameMode.Enabled) { return(true); } if (Cleaner.GameMode.AllRolePlayers.Where(x => x.AmRolePlayer).Count() == 0) { return(true); } #region ----- Check Cooldown ----- if (Cleaner.GameMode.CleanStopwatch.Elapsed.TotalSeconds < Cleaner.GameMode.CleanCooldown) { return(false); } #endregion if (TargetId != byte.MaxValue) { Cleaner.GameMode.removeBody(TargetId); RpcManager.SendRpc(Cleaner.CleanerRpc, new byte[] { (byte)CleanerGameMode.CustomRpc.CleanBody, TargetId }); Cleaner.GameMode.CleanStopwatch.Restart(); TargetId = byte.MaxValue; } return(false); }
//Methods: protected PathELManager(EdgeListener el, bool thread) { _el = el; _sync = new object(); _edges = new List <Edge>(); _unannounced = new Dictionary <Edge, PathEdge>(); _pel_map = new Dictionary <string, PathEdgeListener>(); //Use the reqrep protocol with a special prefix: _rrm = new ReqrepManager("PathELManager:" + el.ToString(), PType.Protocol.Pathing); _rrm.Subscribe(this, null); Rpc = new RpcManager(_rrm); Rpc.AddHandler("sys:pathing", this); _el.EdgeEvent += HandleEdge; _running = true; _next_check = DateTime.UtcNow.Ticks; if (thread) { _timer_thread = new Thread( delegate() { while (_running) { Thread.Sleep(1000); TimeoutCheck(); } } ); _timer_thread.IsBackground = true; _timer_thread.Start(); } }
public void Log(string message, LogLevel level) { if (ClientConfiguration.ConsoleLogLevel > level && ClientConfiguration.MirrorLogLevel > level) { return; } var output = $"{DateTime.Now:s} [{level}]"; if (!string.IsNullOrEmpty(this.Prefix)) { output += $" [{this.Prefix}]"; } var lines = message.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); var formattedMessage = string.Join(Environment.NewLine, lines.Select(l => $"{output} {l}")); if (ClientConfiguration.ConsoleLogLevel <= level) { CitizenFX.Core.Debug.Write($"{formattedMessage}{Environment.NewLine}"); } if (ClientConfiguration.MirrorLogLevel <= level && !message.Contains(CommunicationEvents.LogMirror)) { RpcManager.Emit(CommunicationEvents.LogMirror, DateTime.UtcNow, level, this.Prefix, message); } }
//Methods: protected PathELManager(EdgeListener el, bool thread) { _el = el; _sync = new object(); _edges = new List<Edge>(); _unannounced = new Dictionary<Edge, PathEdge>(); _pel_map = new Dictionary<string, PathEdgeListener>(); //Use the reqrep protocol with a special prefix: _rrm = new ReqrepManager("PathELManager:" + el.ToString(), PType.Protocol.Pathing); _rrm.Subscribe(this, null); Rpc = new RpcManager(_rrm); Rpc.AddHandler("sys:pathing", this); _el.EdgeEvent += HandleEdge; _running = true; _next_check = DateTime.UtcNow.Ticks; if(thread) { _timer_thread = new Thread( delegate() { while(_running) { Thread.Sleep(1000); TimeoutCheck(); } } ); _timer_thread.IsBackground = true; _timer_thread.Start(); } }
public LogManager(Node node) { Node = node; Rpc = node.Rpc; Rpc.AddHandler("LogManager", this); Console = new ConsoleTraceListener(true); }
public override void Start() { //Make sure the Node is listening to this node try { //This will throw an exception if _e is already closed: _e.CloseEvent += this.CloseHandler; //_e must not be closed, let's start listening to it: _e.Subscribe(_node, _e); /* Make the call */ Channel results = new Channel(); results.CloseAfterEnqueue(); results.CloseEvent += this.LinkCloseHandler; RpcManager rpc = _node.Rpc; if (ProtocolLog.LinkDebug.Enabled) { ProtocolLog.Write(ProtocolLog.LinkDebug, String.Format("LPS target: {0} Invoking Start() over edge: {1}", _linker.Target, _e)); } rpc.Invoke(_e, results, "sys:link.Start", MakeLM().ToDictionary()); } catch (Exception e) { //The Edge must have closed, move on to the next TA if (ProtocolLog.LinkDebug.Enabled) { ProtocolLog.Write(ProtocolLog.LinkDebug, String.Format("LPS target: {0} Start() over edge: {1}, hit exception: {2}", _linker.Target, _e, e)); } Finish(Result.MoveToNextTA); } }
private static void RunRemoteSystem() { var serverOptions = (new RpcServerOptions()) .UsingIPAddress("127.0.0.1") .UsingPort(remotePort); var manager = new RpcManager(serverOptions); manager.Start(); var systemOptions = ActorSystemOptions .UsingName(remoteSystem) .UsingErrorHandler( (actorSys, error) => { Console.WriteLine(error); }, (actorSys, process, msg, error) => { Console.WriteLine(error); }); var actorSystem = ActorSystem.GetOrAdd(systemOptions); manager.Bind(actorSystem); var actorOptions = ActorOptions .UsingName(remoteActor); var Completed = Task.FromResult(0); var sw = new Stopwatch(); var pid = actorSystem.FromFunction((ctx, message) => { var count = Interlocked.Increment(ref counter); if (count == 1) { sw.Restart(); } else { if (count % 1000 == 0) { Console.WriteLine(count); } if (count == loop) { Interlocked.Exchange(ref counter, 0); sw.Stop(); Console.WriteLine("Ellapsed time: " + sw.ElapsedMilliseconds); Console.WriteLine("Concurrency: " + (loop * 1000 / sw.ElapsedMilliseconds) + " call per sec"); } } if (message.MessageType == MessageType.FutureMessage) { ctx.RespondTo(message, "world " + count.ToString("000000")); } return(Completed); }, actorOptions); }
/** * Installs the network coordinate service on a given node. * NCService instance can be installed on atmost one node. * Each node is allowed to have only one NCService instance. * @param node node for installing the service instance. * @param InitialPoint a starting place for the NCService to use */ public NCService(Node node, Point InitialPoint) { _sync = new object(); _node = null; _last_sample_instant = DateTime.MinValue; _samples = new Hashtable(); _vivaldi_state = new VivaldiState(); _vivaldi_state.WeightedError = INITIAL_WEIGHTED_ERROR; _vivaldi_state.Position = new Point(); _vivaldi_state.DistanceDelta = 0.0f; if (InitialPoint == null) { InitialPoint = new Point(); } _vivaldi_state.Position = InitialPoint; if (node != null) { _node = node; #if NC_DEBUG Console.Error.WriteLine("[NCService] {0} Starting an instance of NCService.", node.Address); #endif lock (_sync) { _rpc = _node.Rpc; _rpc.AddHandler("ncserver", this); _node.HeartBeatEvent += GetNextSample; } } }
public bool HandleReply(ReqrepManager man, ReqrepManager.ReqrepType rt, int mid, PType prot, MemBlock payload, ISender returnpath, ReqrepManager.Statistics statistics, object state) { DateTime reply_time = DateTime.UtcNow; ListDictionary res_dict = new ListDictionary(); AHSender ah_rp = returnpath as AHSender; if (ah_rp != null) { res_dict["target"] = ah_rp.Destination.ToString(); } //Here are the number of microseconds res_dict["musec"] = (int)(1000.0 * ((reply_time - _start_time).TotalMilliseconds)); //Send the RPC result now; RpcManager my_rpc = System.Threading.Interlocked.Exchange(ref _rpc, null); if (my_rpc != null) { //We have not sent any reply yet: my_rpc.SendResult(_req_state, res_dict); } return(false); }
static void Ping(IList nodes) { Random my_r = new Random(); int idx0 = my_r.Next(0, nodes.Count); int idx1 = my_r.Next(0, nodes.Count); Node n0 = (Node)nodes[idx0]; Node n1 = (Node)nodes[idx1]; RpcManager pinger = n0.Rpc; Channel results = new Channel(); results.EnqueueEvent += delegate(object q, EventArgs a) { object result = results.Dequeue(); RpcResult r = (RpcResult)result; try { IDictionary data = (IDictionary)r.Result; Console.WriteLine("target: {0}, rtt: {1}", data["target"], data["musec"]); } catch (Exception x) { Console.WriteLine("target: {0}, Exception: {1}", n1.Address, x); } }; Console.WriteLine("Pinging: {0} -> {1}", n0.Address, n1.Address); try { pinger.Invoke(n0, results, "trace.GetRttTo", n1.Address.ToString()); } catch (Exception x) { Console.WriteLine("Exception: {0}", x); } }
override public void Start() { ProtocolLog.WriteIf(ProtocolLog.LinkDebug, String.Format("{0}: Starting Connector: {1}, {2}", _local_node.Address, _sender, State)); AbortCheck ac = _abort.Value; if (ac != null) { if (ac(this)) { //We are no longer needed: QueueCloseHandler(null, null); return; } } RpcManager rpc = _local_node.Rpc; Channel results = new Channel(); results.EnqueueEvent += this.EnqueueHandler; results.CloseEvent += this.QueueCloseHandler; try { rpc.Invoke(_sender, results, "sys:ctm.ConnectTo", _ctm.ToDictionary()); } catch { //Looks like the _sender had some problem: QueueCloseHandler(null, null); } }
private void OnTime_ValueChanged(object sender, CustomNumberOption.CustomNumberOptionEventArgs e) { switch (e.NumberOption.TitleText) { case "Ability On Time": { int value = int.Parse(e.NumberOption.ValueStrings[e.NumberOption.Value]); OnTime = value; var writer = RpcManager.StartRpc(QuantumTunneling.QuantumTunnelingRpc); writer.Write((byte)0); writer.Write(OnTime); writer.EndMessage(); break; } case "Ability Cooldown": { int value = int.Parse(e.NumberOption.ValueStrings[e.NumberOption.Value]); UseCooldown = value; var writer = RpcManager.StartRpc(QuantumTunneling.QuantumTunnelingRpc); writer.Write((byte)1); writer.Write(UseCooldown); writer.EndMessage(); break; } } }
private static IAsyncResult ProcessReqeustInternal(HttpContext context, AsyncCallback cb, object extraData) { var task = RpcManager.ProcessAsync(new AspNetServerContext(context)); var waitTask = ToBegin(task, cb, extraData); return(waitTask); }
public static bool Prefix() { var local = PlayerController.LocalPlayer; if (!BattleRoyale.GameMode.IsInGame || Target == null || (Functions.GetUnixTime() - BattleRoyale.GameMode.LastKilled < GameOptions.KillCooldown && BattleRoyale.GameMode.LastKilled != 0) || local.PlayerData.IsDead) { return(true); } var target = Target; BattleRoyale.GameMode.LastKilled = Functions.GetUnixTime(); #region ---------- Write Kill ---------- if (CheepsAmongUsMod.CheepsAmongUsMod.IsDecidingClient) { var killer = PlayerController.LocalPlayer; if (!killer.PlayerData.IsDead && !target.PlayerData.IsDead && CheepsAmongUsMod.CheepsAmongUsMod.IsDecidingClient) { RpcManager.SendRpc(BattleRoyale.BattleRoyalRpc, new byte[] { (byte)BattleRoyale.CustomRpcCalls.MurderPlayer, killer.PlayerId, target.PlayerId }); killer.PlayerControl.MurderPlayer(target.PlayerControl); target.PlayerData.IsDead = true; } } else { RpcManager.SendRpc(BattleRoyale.BattleRoyalRpc, new byte[] { (byte)BattleRoyale.CustomRpcCalls.KillPlayer, PlayerController.LocalPlayer.PlayerId, Target.PlayerId }); } #endregion return(false); }
private static void InitSystem(int port) { var serverOptions = (new RpcServerOptions()) .UsingIPAddress("127.0.0.1") .UsingPort(port); var manager = new RpcManager(serverOptions); manager.Start(); var systemOptions = ActorSystemOptions .UsingName("system-2") .UsingErrorHandler( (actorSys, error) => { Console.WriteLine(error); }, (actorSys, process, msg, error) => { Console.WriteLine(error); }); var actorSystem = ActorSystem.GetOrAdd(systemOptions); manager.Bind(actorSystem); var remoteActorOptions = ActorOptions .UsingName("system-1-actor-1") .UsingRemoteActorSystem("system-1") .UsingRemoteEndPoint("127.0.0.1", 17777); actorSystem.FromRemote(remoteActorOptions); }
public override void OnStart() { base.OnStart(); Task.Run(async() => { await Task.Delay(2500); MaxPlayerCount = PlayerController.AllPlayerControls.Count; Started = true; LastKilled = 0; PlayerController.LocalPlayer.ClearTasks(); #region ---------- Send Start Location ---------- if (RandomStartLocation && CheepsAmongUsMod.CheepsAmongUsMod.IsDecidingClient && MapLocations.ContainsKey(GameOptions.Map)) { List <Vector2> Locations = new List <Vector2>(MapLocations[GameOptions.Map]); System.Random rnd = new System.Random(); foreach (var player in PlayerController.AllPlayerControls) { if (Locations.Count == 0) { Locations.AddRange(MapLocations[GameOptions.Map]); // If there are not enough start locations, refill list } var location = Locations[rnd.Next(Locations.Count)]; Locations.Remove(location); if (!player.IsLocalPlayer) { var writer = RpcManager.StartRpc(BattleRoyale.BattleRoyalRpc); writer.Write((byte)BattleRoyale.CustomRpcCalls.SendStartLocation); writer.Write(player.PlayerId); writer.Write(location.x); writer.Write(location.y); writer.EndMessage(); } else { player.RpcSnapTo(location); } } } #endregion #region ---------- Open All Doors ---------- await Task.Delay(2500); foreach (var door in UnityEngine.Object.FindObjectsOfType <DeconDoor>()) { door.SetDoorway(true); } #endregion LastKilled = Functions.GetUnixTime(); }); }
/** * <summary>Creates an Information object for the node and type of service * provider.</summary> * <param name="node">The node where the service is to be provided</param> * <param name="type">The name of the application providing service (example: * BasicNode)</param> */ public Information(StructuredNode node, String type) { UserData = new Hashtable(); _type = type; _node = node; _rpc = node.Rpc; _rpc.AddHandler("Information", this); }
public LocalDiscovery(ITAHandler ta_handler, string realm, RpcManager rpc, IPHandler iphandler) : base(ta_handler) { _rpc = rpc; _iphandler = iphandler; _realm = realm; _rpc.AddHandler(RPC_CLASS, this); }
private void SyncDelay() { var writer = RpcManager.StartRpc(Teleportation.TeleportationRpc); writer.Write((byte)0); writer.Write(TeleportationDelay); writer.EndMessage(); }
/// <summary>Initiates a RpcProxyHandler instance. It uses reflection for rpc call. /// Thus, it does not have to inherit IRpcHanler.This instance keeps Entry /// to keep track of key, value, and ttl</summary> /// <param name="node">node which is currently connected.</param> /// <param name="dht">IDht instance</param> public RpcDhtProxy(IDht dht, Node node) { _entries = new Dictionary<MemBlock, Dictionary<MemBlock, Entry>>(); _rpc = node.Rpc; _dht = dht; _sync = new Object(); _rpc.AddHandler("RpcDhtProxy", this); }
/// <summary>Initiates a RpcProxyHandler instance. It uses reflection for rpc call. /// Thus, it does not have to inherit IRpcHanler.This instance keeps Entry /// to keep track of key, value, and ttl</summary> /// <param name="node">node which is currently connected.</param> /// <param name="dht">IDht instance</param> public RpcDhtProxy(IDht dht, Node node) { _entries = new Dictionary <MemBlock, Dictionary <MemBlock, Entry> >(); _rpc = node.Rpc; _dht = dht; _sync = new Object(); _rpc.AddHandler("RpcDhtProxy", this); }
private void SendSwapDelay() { var writer = RpcManager.StartRpc(ColorSwap.ColorSwapRpc); writer.Write((byte)0); writer.Write(SwapDelay); writer.EndMessage(); }
public SocialRpcHandler(StructuredNode node, SocialUser localUser, Dictionary <string, SocialUser> friends) { _node = node; _rpc = node.Rpc; _rpc.AddHandler("SocialVPN", this); _local_user = localUser; _friends = friends; }
private void sync() { RpcManager.SendRpc(Cleaner.CleanerRpc, new byte[] { (byte)CustomRpc.UpdateSettings, Convert.ToByte(Enabled) }); var writer = RpcManager.StartRpc(Cleaner.CleanerRpc); writer.Write((byte)CustomRpc.UpdateCooldown); writer.Write(CleanCooldown); writer.EndMessage(); }
/// <summary>A default Dht client provides a DEGREE of 1 and a sychronous wait /// time of up to 60 seconds.</summary> /// <param name ="node">The node to provide service for.</param> public Dht(Node node) { Node = node; _rpc = node.Rpc; _sync = new object(); StateChangeHandler(Node, Node.ConState); Node.StateChangeEvent += StateChangeHandler; DEGREE = 1; MAJORITY = 1; DELAY = 60000; }
public void Reply(params object[] payloads) { if (this._networked) { RpcManager.Emit($"{this.Id}:{this.Event}", payloads); } else { this._eventManager.Emit($"{this.Id}:{this.Event}", payloads); } }
public void Reply(params object[] payloads) { if (this.Client == null) { this._eventManager.Emit($"{this.Id}:{this.Event}", payloads); } else { RpcManager.Emit($"{this.Id}:{this.Event}", this.Client, payloads); } }
/** <summary>Creates a new TableServer object and registers it to the "dht" handler in the node's RpcManager.</summary> <param name="node">The node the dht is to serve from.</param> */ public TableServer(Node node) { _sync = new Object(); _transfer_sync = new Object(); _node = node; _rpc = node.Rpc; _data = new TableServerData(_node); lock(_transfer_sync) { node.ConnectionTable.ConnectionEvent += this.ConnectionHandler; node.ConnectionTable.DisconnectionEvent += this.ConnectionHandler; _node.StateChangeEvent += StateChangeHandler; } _rpc.AddHandler("dht", this); }
/// <summary> /// The overloaded method for now is used to allow RpcManager to be replaced /// by MockRpcManager in unit tests. /// </summary> /// <param name="node"></param> /// <param name="rpc"></param> /// <param name="uri"></param> internal void Add(Node node, RpcManager rpc, string uri) { var xrm = new XmlRpcManager(node, rpc); lock (_sync_root) { // throw an exception if this mapping exists... _xrm_mappings.Add(node, xrm); RemotingServices.Marshal(xrm, uri); CheckAndSetDefaultManager(); } rpc.AddHandler("xmlrpc", xrm); }
public XmlRpcManager(Node node, RpcManager rpc, BrunetSecurityOverlord bso) : this(node, rpc) { _bso = bso; }
public void Update(Node node, BrunetSecurityOverlord bso) { RpcManager rpc = RpcManager.GetInstance(node); _rpc = rpc; _node = node; _xrm = new XmlRpcManager(_node, _rpc, bso); _rpc.AddHandler("xmlrpc", _xrm); RemotingServices.Marshal(_xrm, "xm.rem"); }
/* <summary>Create a new set of chached data(For now, data is strings).</summary> * */ public CacheList(Node node) { _node = node; _rpc = RpcManager.GetInstance(node); ///add handler for deetoo data insertion and search. _rpc.AddHandler("Deetoo", new DeetooHandler(node,this)); }
/** * The overloaded method for now is used to allow RpcManager to be replaced * by MockRpcManager in unit tests. public void Update(Node node, RpcManager rpc) { _rpc = rpc; _node = node; _xrm = new XmlRpcManager(_node, _rpc); _rpc.AddHandler("xmlrpc", _xrm); RemotingServices.Marshal(_xrm, "xm.rem"); } */ public void Update(Node node, RpcManager rpc) { Update(node,""); }
/** * The overloaded method for now is used to allow distinct Uri for multiple XmlRpcManagerServer. */ public void Update(Node node, string type) { RpcManager rpc = RpcManager.GetInstance(node); _rpc = rpc; _node = node; _xrm = new XmlRpcManager(_node, _rpc); _rpc.AddHandler("xmlrpc", _xrm); string svc_name = type + "xm.rem"; RemotingServices.Marshal(_xrm, svc_name); }
/** * Create a node with a given local address and * a set of Routers. * @param addr Address for the local node * @param realm the Realm or Namespace this node belongs to */ protected Node(Address addr, string realm) { //Start with the address hashcode: _sync = new Object(); lock(_sync) { DemuxHandler = new DemuxHandler(); /* * Make all the hashtables : */ _local_add = AddressParser.Parse( addr.ToMemBlock() ); _realm = String.Intern(realm); /* Set up the heartbeat */ _heart_period = 500; //500 ms, or 1/2 second. _heartbeat_handlers = new Dictionary<EventHandler, Brunet.Util.FuzzyEvent>(); _task_queue = new NodeTaskQueue(this); _packet_queue = new BCon.LFBlockingQueue<IAction>(); _running = 0; _send_pings = 1; _LOG = ProtocolLog.Monitor.Enabled; _connection_table = new ConnectionTable(new DefaultERPolicy(addr)); _connection_table.ConnectionEvent += this.ConnectionHandler; LockMgr = new ConnectionLockManager(_connection_table); //We start off offline. _con_state = Node.ConnectionState.Offline; /* Set up the ReqrepManager as a filter */ _rrm = new ReqrepManager(this.ToString()); DemuxHandler.GetTypeSource(PType.Protocol.ReqRep).Subscribe(_rrm, null); _rrm.Subscribe(this, null); this.HeartBeatEvent += _rrm.TimeoutChecker; /* Set up RPC */ _rpc = new RpcManager(_rrm); DemuxHandler.GetTypeSource( PType.Protocol.Rpc ).Subscribe(_rpc, null); //Add a map-reduce handlers: _mr_handler = new MR.MapReduceHandler(this); //Subscribe it with the RPC handler: _rpc.AddHandler("mapreduce", _mr_handler); /* * Where there is a change in the Connections, we might have a state * change */ _connection_table.ConnectionEvent += this.CheckForStateChange; _connection_table.DisconnectionEvent += this.CheckForStateChange; #if !BRUNET_SIMULATOR _codeinjection = new Brunet.Services.CodeInjection(this); _codeinjection.LoadLocalModules(); #endif /* * We must later make sure the EdgeEvent events from * any EdgeListeners are connected to _cph.EdgeHandler */ /** * Here are the protocols that every edge must support */ /* Here are the transport addresses */ _remote_ta = ImmutableList<TransportAddress>.Empty; /*@throw ArgumentNullException if the list ( new ArrayList()) is null. */ /* EdgeListener's */ _edgelistener_list = new ArrayList(); _co_list = new List<ConnectionOverlord>(); _edge_factory = new EdgeFactory(); _ta_discovery = ImmutableList<Discovery>.Empty; StateChangeEvent += HandleTADiscoveryState; /* Initialize this at 15 seconds */ _connection_timeout = new TimeSpan(0,0,0,0,15000); //Check the edges from time to time IAction cec_act = new HeartBeatAction(this, this.CheckEdgesCallback); _check_edges = Brunet.Util.FuzzyTimer.Instance.DoEvery(delegate(DateTime dt) { this.EnqueueAction(cec_act); }, 5000, 500); } }
public RpcSendResultAction(RpcManager rpc, object rs, object result) { _rpc = rpc; _rs = rs; _result = result; }
/** * Installs the network coordinate service on a given node. * NCService instance can be installed on atmost one node. * Each node is allowed to have only one NCService instance. * @param node node for installing the service instance. * @param InitialPoint a starting place for the NCService to use */ public NCService(Node node, Point InitialPoint) { _sync = new object(); _node = null; _last_sample_instant = DateTime.MinValue; _samples = new Hashtable(); _vivaldi_state = new VivaldiState(); _vivaldi_state.WeightedError = INITIAL_WEIGHTED_ERROR; _vivaldi_state.Position = new Point(); _vivaldi_state.DistanceDelta = 0.0f; if(InitialPoint == null) { InitialPoint = new Point(); } _vivaldi_state.Position = InitialPoint; if(node != null) { _node = node; #if NC_DEBUG Console.Error.WriteLine("[NCService] {0} Starting an instance of NCService.", node.Address); #endif lock(_sync) { _rpc = _node.Rpc; _rpc.AddHandler("ncserver", this); _node.HeartBeatEvent += GetNextSample; } } }
public XmlRpcManager(Node node, RpcManager rpc) { _node = node; _rpc = rpc; }
/** <summary>This handles only connection event for now.<\summary> <param name="node">The node the deetoo is to serve from.<\param> <param name="cl">The CacheList belongs to this node.<\param> */ public DeetooHandler(Node node, CacheList cl) { _node = node; _rpc = RpcManager.GetInstance(node); _cl = cl; //NetworkSize = _node.NetworkSize; _local_network_size = _node.NetworkSize; _median_network_size = _node.NetworkSize; node.ConnectionTable.ConnectionEvent += this.GetEstimatedSize; node.ConnectionTable.DisconnectionEvent += this.GetEstimatedSize; node.ConnectionTable.ConnectionEvent += this.GetMedianEstimation; node.ConnectionTable.DisconnectionEvent += this.GetMedianEstimation; node.ConnectionTable.ConnectionEvent += this.ConnectionHandler; //_rpc.AddHandler("Deetoo", this); }
/** * The overloaded method for now is used to allow RpcManager to be replaced * by MockRpcManager in unit tests. */ public void Update(Node node, RpcManager rpc) { _rpc = rpc; _node = node; _xrm = new XmlRpcManager(_node, _rpc); _rpc.AddHandler("xmlrpc", _xrm); RemotingServices.Marshal(_xrm, "xm.rem"); }
public SocialConnectionManager(SocialNode node, RpcManager rpc, SocialDnsManager sdm, SocialStatsManager ssm, SocialConfig config) { _rpc = rpc; _rpc.AddHandler(RPCID, this); _sdm = sdm; _node = node; _ssm = ssm; _networks = ImmutableDictionary<string, ISocialNetwork>.Empty; _fprs = ImmutableDictionary<string, string>.Empty; _times = ImmutableDictionary<string, System.DateTime>.Empty; _pending = ImmutableList<string>.Empty; _blocked = ImmutableList<string>.Empty; _beat_counter = 0; _auto_allow = config.AutoFriend; _sdm.Sender = this; #if !SVPN_NUNIT _timer = new Timer(TimerHandler, _beat_counter, PERIOD, PERIOD); LoadState(); #endif }
/** * @param url the URL of the XML-RPC service. * @param rpc The XmlRpcManager instance that the handler uses. */ public XmlRpcHandler(string url, Node node) { this.Url = url; _node = node; _rpc = _node.Rpc; }