public void Use(IClient client, string commandName, string[] tokens) { if (client.Point2 == null || client.Point1 == null) { client.SendMessage("§cPlease select a cuboid first."); return; } UniversalCoords start = client.SelectionStart.Value; UniversalCoords end = client.SelectionEnd.Value; IItemStack item = client.GetOwner().GetServer().GetItemDb().GetItemStack(tokens[0]); if (item == null || item.IsVoid()) { client.SendMessage("§cUnknown item."); return; } if (item.Type > 255) { client.SendMessage("§cInvalid item."); } for (int x = start.WorldX; x <= end.WorldX; x++) { for (int y = start.WorldY; y <= end.WorldY; y++) { for (int z = start.WorldZ; z <= end.WorldZ; z++) { client.GetOwner().GetWorld().SetBlockAndData(UniversalCoords.FromWorld(x, y, z), (byte)item.Type, (byte)item.Durability); } } } }
public void Setup() { _client = MockRepository.GenerateMock<IClient>(); _fs = MockRepository.GenerateMock<IFS>(); _locator = new EngineLocator(_fs); _locator.ClientFactory = () => { return _client; }; }
public ViewsFixture() { Artists = TestData.Artists.CreateArtists(10); _client = IntegrationTestsRuntime.CreateClient(); var bulk = new BulkCommand(); bulk.Include(Artists.Select(i => _client.Entities.Serializer.Serialize(i)).ToArray()); var bulkResponse = _client.Documents.BulkAsync(bulk); foreach (var row in bulkResponse.Result.Rows) { var artist = Artists.Single(i => i.ArtistId == row.Id); _client.Entities.Reflector.RevMember.SetValueTo(artist, row.Rev); } _client.Documents.PostAsync(TestData.Views.Artists).Wait(); var touchView1 = new ViewQuery(TestData.Views.ArtistsAlbumsViewId).Configure(q => q.Stale(Stale.UpdateAfter)); var touchView2 = new ViewQuery(TestData.Views.ArtistsNameNoValueViewId).Configure(q => q.Stale(Stale.UpdateAfter)); _client.Views.RunQueryAsync(touchView1).Wait(); _client.Views.RunQueryAsync(touchView2).Wait(); }
public object execute(IClient client, string command) { if (client != null) { string source = ""; Match match = Regex.Match(command, "\"(.*)\"", RegexOptions.IgnoreCase); string[] args = command.Replace(" ", "").Split(','); if (match.Success) { source = match.Groups[1].Value; } else { source = args[2]; } int fileRegister1; Int32.TryParse(args[1], out fileRegister1); string semantics = args[2]; int fileRegister2; Int32.TryParse(args[3], out fileRegister2); string salt = source; client.Copy(fileRegister1, semantics, fileRegister2, salt); } return null; }
public bool InitRemotableObjekt(int pin_Port, string pin_URL) { try { // Creates a proxy for the well-known object // indicated by the specified type and URL. IDictionary prop = new Hashtable(); prop["name"] = "tcppELSClient"; prop["port"] = pin_Port.ToString(); ChannelServices.RegisterChannel(new TcpChannel(prop, null, null)); this._proxyClient = (IClient)Activator.GetObject( // type of object typeof(IClient), // specified URL pin_URL); Console.WriteLine("Remoting initialized"); return true; } catch(Exception e) { Console.WriteLine(e.ToString()); return false; } }
public IndexOperations(IClient client, ILogger logger = null, IScroller scroller = null, IIndexer indexer = null, ISearcher searcher = null) { _logger = logger; _searcher = searcher ?? new Searcher(client, logger); _scroller = scroller ?? new Scroller(client, logger); _indexer = indexer ?? new Indexer(client, logger); }
public FileExplorerForm(IServerUIHandler UIHandler, IClient c) { Client = c; UIHost = UIHandler; InitializeComponent(); Image uiFolder = UIHandler.GetImage("folder.png"); Image uiFolder2 = UIHandler.GetImage("folder2.png"); Image uiFile = UIHandler.GetImage("file.png"); Image uiDrive = UIHandler.GetImage("drive.png"); Image uiError = UIHandler.GetImage("error.png"); if(uiFolder != null) images.Images.Add("Folder", uiFolder); if (uiFolder2 != null) images.Images.Add("Folder2", uiFolder2); if (uiFile!=null) images.Images.Add("File", uiFile); if(uiDrive!=null) images.Images.Add("Drive", uiDrive); if(uiError != null) images.Images.Add("Error", uiError); lvFileView.SmallImageList = images; lvFileBucket.SmallImageList = images; c.Send((byte)NetworkCommand.FileManager, (byte)FileManagerCommand.Update, string.Empty); }
public void Show(IClient client) { if (!Visible) { this.client = client; Open (); } }
public EditStopLimitOrderViewModel(IClient client, StopLimitOrderDto stopLimitOrder) { this.client = client; this.stopLimitOrder = stopLimitOrder; SetFields(stopLimitOrder); SetupCommandsAndBehaviour(); }
protected override PacketData ProcessData(IClient sender, Guid cid, object command, dynamic data) { var userCommand = (UserGameCommand)command; var dataToReturn = new PacketData(cid, command, data); switch (userCommand) { case UserGameCommand.Unknown: break; case UserGameCommand.PlayerJoin: sender.UserToken = cid; var dataToSendOther = new PacketData(cid, command, data); SendRespone(Clients.Where(x=>!x.Value.Equals(sender)).Select(x => x.Value), dataToSendOther); foreach (var client in Clients.Where(x => !x.Value.Equals(sender)).Select(x => x.Value)) { var dataToReturnSender = new PacketData((Guid?)client.UserToken, command, data); SendRespone(Clients.Where(x => x.Value.Equals(sender)).Select(x => x.Value), dataToReturnSender); } return null; break; case UserGameCommand.PlayerLeave: break; default: throw new ArgumentOutOfRangeException(); } return dataToReturn; }
public void Use(IClient iClient, string commandName, string[] tokens) { Client client = iClient as Client; client.SendMessage("Online Players: " + client.Owner.Server.Clients.Count); foreach (Client c in client.Owner.Server.GetAuthenticatedClients()) client.SendMessage(c.Owner.EntityId + " : " + c.Owner.DisplayName); }
public Refunds(ILog logger, IClient client, string createAddress = Createrefundsaddress, string validateAddress = Validaterefundsaddress) : base(logger, client, createAddress) { _validateRefundAddress = validateAddress; }
protected override void DoInteraction(IClient iClient, IItemInventory item) { base.DoInteraction(iClient, item); Client client = iClient as Client; if (client == null) return; if (item != null && !ItemHelper.IsVoid(item)) { if (item.Type == (short)BlockData.Items.Raw_Fish && !Data.IsTamed) { FishUntilTamed--; client.Owner.Inventory.RemoveItem(item.Slot); // consume the item if (FishUntilTamed <= 0) { Data.IsTamed = true; Data.TamedBy = client.Username; Health = MaxHealth; // TODO: begin following this.Data.TamedBy SendMetadataUpdate(); } } } }
public bool Add(IClient client) { if (client == null) throw new ArgumentNullException("client"); if (ClientCount >= MaxClients) { Log.Default.WriteLine(LogLevels.Warning, "Too many clients"); return false; } if (_clients.ContainsKey(client.Callback)) { Log.Default.WriteLine(LogLevels.Warning, "{0} already connected", client.Name); return false; } if (_clients.Any(x => x.Value.Name == client.Name)) { Log.Default.WriteLine(LogLevels.Warning, "{0} already connected", client.Name); return false; } // _clients.Add(client.Callback, client); // return true; }
public void Show (IClient connectingClient) { if (!Visible) { client = connectingClient; Open (); } }
/// <summary> /// Process the peer messages /// </summary> private void PeerOnMessageReceivedEvent(IClient sender, MessageEventArgs messageArgs) { var message = messageArgs.Message; if (message == null) return; switch (message.TypeOfMessage) { case MessageType.Request: switch (((RequestMessage)message).RequestedMessageType) { case MessageType.Ping: _superPeerNode.GetClientInfo().LastPingMesssageDateTime = DateTime.Now; break; case MessageType.CloseConnection: _superPeerNode.GetSuperPeerClient().Close(); break; } break; default: if (_superPeerNode is SuperPeerClient) new ClientMessageManager((SuperPeerClient)_superPeerNode).ClientPeerOnMessageReceivedEvent(sender, messageArgs); else if (_superPeerNode is SuperPeerServer) new ServerMessageManager((SuperPeerServer)_superPeerNode).ServerPeerOnMessageReceivedEvent(sender, messageArgs); break; } }
public void Setup() { this.databaseName = "data"; this.clientMock = new Mock<IClient>(); this.client = this.clientMock.Object; }
public static void Disconnect(IClient c) { if (FormHandler.ContainsKey(c.ID)) { FormHandler[c.ID].Close(); } }
public SetDateCommand(TaskArgsConverter converter, TextWriter textWriter, IClient client) { this.converter = converter; this.textWriter = textWriter; this.client = client; Description = "Sets due date for task, specified by ID."; }
public CompleteCommand(TaskArgsConverter converter, TextWriter textWriter, IClient client) { this.converter = converter; this.textWriter = textWriter; this.client = client; Description = "Mark task by ID as completed."; }
public ViewsFixture() { Artists = ClientTestData.Artists.CreateArtists(10); Client = IntegrationTestsRuntime.CreateNormalClient(); var bulk = new BulkRequest(); bulk.Include(Artists.Select(i => Client.Entities.Serializer.Serialize(i)).ToArray()); var bulkResponse = Client.Documents.BulkAsync(bulk).Result; foreach (var row in bulkResponse.Rows) { var artist = Artists.Single(i => i.ArtistId == row.Id); Client.Entities.Reflector.RevMember.SetValueTo(artist, row.Rev); } var tmp = Client.Documents.PostAsync(ClientTestData.Views.ArtistsViews).Result; var touchView1 = new QueryViewRequest(ClientTestData.Views.ArtistsAlbumsViewId).Configure(q => q.Stale(Stale.UpdateAfter)); var touchView2 = new QueryViewRequest(ClientTestData.Views.ArtistsNameNoValueViewId).Configure(q => q.Stale(Stale.UpdateAfter)); var touchView3 = new QueryViewRequest(ClientTestData.Views.ArtistsTotalNumOfAlbumsViewId).Configure(q => q.Stale(Stale.UpdateAfter)); Client.Views.QueryAsync(touchView1).Wait(); Client.Views.QueryAsync(touchView2).Wait(); Client.Views.QueryAsync(touchView3).Wait(); }
public AuthService(IClient client) { if (client == null) throw new ArgumentNullException(nameof(client)); _client = client; }
public void ExecuteRequest(IClient client, Packet packetIn) { Logger.Trace("RPC:Storage:ExecuteRequest()"); var request = bnet.protocol.storage.ExecuteRequest.ParseFrom(packetIn.Payload.ToArray()); //Logger.Debug("request:\n{0}", request.ToString()); bnet.protocol.storage.ExecuteResponse response = null; switch (request.QueryName) { case "GetGameAccountSettings": response = GameAccountSettings(request); break; case "LoadAccountDigest": response = LoadAccountDigest(request); break; case "GetHeroDigests": response = GetHeroDigest(request); break; case "GetToonSettings": response = GetToonSettings(request); break; default: Logger.Warn("Unhandled ExecuteRequest: {0}", request.QueryName); break; } var packet = new Packet( new Header(0xfe, 0x0, packetIn.Header.RequestID, (uint)response.SerializedSize), response.ToByteArray()); client.Send(packet); }
public void Use(IClient client, string commandName, string[] tokens) { if (tokens.Length < 1) { Help(client); return; } var toKick = client.GetServer().GetClients(); if (toKick.Any() && tokens[0].ToLower() != "all") { foreach (var client1 in toKick.Where(client1 => !client1.GetOwner().CanUseCommand("chraft.kick.exempt"))) { client1.Kick(tokens.Length > 1 ? tokens[1] : "Kicked"); client.SendMessage("Kicked " + client1.GetOwner().Name); } } else { foreach (IClient t in toKick.Where(t => t.GetOwner().Name.ToLower() == tokens[0].ToLower()).Where(t => !t.GetOwner().CanUseCommand("chraft.kick.exempt"))) { t.Kick(tokens.Length > 1 ? tokens[1] : "Kicked"); client.SendMessage("Kicked " + t.GetOwner().Name); } } }
public NotificationContainer(IClient client, bool status) { Value = status; Client = client; Type = NotificationType.StatusUpdate; TimeStamp = DateTime.Now; }
public QpidResourceHolder(IClientFactory connectionFactory, IClient connection, IClientSession channel) { this.clientFactory = connectionFactory; AddConnection(connection); AddChannel(channel); this.frozen = true; }
public TabComplete(IClient client) { this.client = client; this.tabHandlers = new TypeList<ITabHandler>( TypeHelpers.ClassesForInterfaceInAssembly<ITabHandler>().ToList() ); }
public static void Identify(IClient client, CodedInputStream stream) { var header = new Header(stream); var payload = new byte[header.PayloadLength]; payload = stream.ReadRawBytes((int)header.PayloadLength); var packet = new Packet(header, payload); var service = Service.GetByID(header.ServiceID); if (service == null) { Logger.Error("No service exists with id: 0x{0}", header.ServiceID.ToString("X2")); return; } var method = service.DescriptorForType.Methods[(int)header.MethodID - 1]; var proto = service.GetRequestPrototype(method); var builder = proto.WeakCreateBuilderForType(); try { var message = builder.WeakMergeFrom(CodedInputStream.CreateInstance(packet.Payload.ToArray())).WeakBuild(); ((IServerService) service).Client = client; service.CallMethod(method, null, message, (msg => SendResponse(client, header.RequestID, msg))); } catch (NotImplementedException) { Logger.Debug(string.Format("Unimplemented service method: {0} {1}", service.GetType().Name, method.Name)); } catch(Exception e) { Logger.DebugException(e,string.Empty); } }
public static void HandleMessage(Packet packet, IClient client, bool fromQueue) { Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply); client.EnterGame(); client.Character.Map.Enter(client.Character, WarpAnimation.Admin); reply.AddShort((short)WelcomeReply.WorldInfo); reply.AddBreak(); for (int i = 0; i < 9; ++i) { reply.AddBreakString("A"); } reply.AddChar(client.Character.Weight); // Weight reply.AddChar(client.Character.MaxWeight); // Max Weight // Inventory foreach (ItemStack item in client.Character.Items) { reply.AddShort(item.Id); reply.AddInt(item.Amount); } reply.AddBreak(); // Spells reply.AddBreak(); IEnumerable<Character> characters = client.Character.GetInRange<Character>(); IEnumerable<NPC> npcs = client.Character.GetInRange<NPC>(); IEnumerable<MapItem> items = client.Character.GetInRange<MapItem>(); reply.AddChar((byte)characters.Count()); reply.AddBreak(); // Characters // { foreach (Character character in characters) { character.InfoBuilder(ref reply); reply.AddBreak(); } // } // NPCs foreach (NPC npc in npcs) { npc.InfoBuilder(ref reply); } reply.AddBreak(); // Items foreach (MapItem item in items) { item.InfoBuilder(ref reply); } client.Send(reply); }
private static bool IsOnline(IClient client) { foreach (IClient c in onlineUsers) if (c.ID == client.ID) return true; return false; }
public async Task Run(string[] args, ILog logger = null, IClient client = null) { Console.CancelKeyPress += Console_CancelKeyPress; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; DIContainer.Current.Register <ILog, ConsoleLogger>("Debug"); if (logger == null) { Logger = DIContainer.Current.Resolve <ILog>(); } else { Logger = logger; } if (client == null) { // insert application code here Client = new SimpleClient.SimpleClient(Environments.Production, new Configuration { ClientId = "f1b18a19-f810-4f16-8a39-d6135f5ec052", ClientSecret = "aead4980-c966-4a26-abee-6bdb1ea23e5c", RedirectUri = "https://www.moj.io" }); } else { Client = client; } string input = null; if (args != null) { input = string.Join(" ", args); } if (!string.IsNullOrEmpty(input) && File.Exists(input)) { await ExecuteFile(input, Client); return; } if (!string.IsNullOrEmpty(input)) { await ExecuteSingle(input, Client); return; } while (true) { try { var username = Client?.Authorization?.UserName; if (string.IsNullOrEmpty(username)) { username = "******"; } Console.Write($"{Client.Configuration.Environment.SelectedEnvironment}:{username}-mojio-:>"); input = Console.ReadLine(); var check = input.ToLowerInvariant().Trim(); if (check == "q" || check == "quit" || check == "exit") { break; } Console.WriteLine(""); await Execute(input, Client); } catch (Exception e) { Logger.Error(e); } } }
public override void AddClient(IClient client) => throw new NotImplementedException();
public GameClient(IClient client) { this.Client = client; }
public ClientDecorator(IClient client) { this.client = client; }
public FindSearchPageController(IClient searchClient, IFindUIConfiguration findUIConfiguration, IRequiredClientResourceList requiredClientResourceList) { this.searchClient = searchClient; this.findUIConfiguration = findUIConfiguration; this.requiredClientResourceList = requiredClientResourceList; }
/// <summary> /// Retrieves then deserializes a JSON object up from the stream /// </summary> /// <typeparam name="T"></typeparam> /// <param name="client"></param> /// <returns>Deserialized object</returns> public static T ReadJson <T>(this IClient client) => JsonSerializer.Deserialize <T>(client?.Read());
/// <summary> /// Serializes then writes an object in JSON format down the stream /// </summary> /// <typeparam name="T">Type of the object to be send</typeparam> /// <param name="client">The SocketCom API client object</param> /// <param name="data">The data object to be send</param> public static void WriteJson <T>(this IClient client, T data) => client?.Write(JsonSerializer.Serialize <T>(data));
private static async Task MonitorVehicles(IClient client, CancellationToken?cancellationToken = null, Action <IVehicle> changedAction = null) { var log = DIContainer.Current.Resolve <ILog>(); if (client == null || client.Configuration == null || client.Configuration.Environment == null) { return; } if (cancellationToken == null) { cancellationToken = DIContainer.Current.Resolve <CancellationToken>(); } while (!cancellationToken.Value.IsCancellationRequested) { var vehicles = await client.Vehicles(top : 1000, cancellationToken : cancellationToken, skipCache : true); if (vehicles != null && vehicles.Response != null && vehicles.Response.Data != null) { foreach (var v in vehicles.Response.Data) { if (cancellationToken.Value.IsCancellationRequested) { return; } var fire = false; if (lastContactTimes.ContainsKey(v.Id)) { var last = lastContactTimes[v.Id]; if (v.LastContactTime > last) // || (DateTimeOffset.UtcNow - v.LastContactTime) > TimeSpan.FromSeconds(10)) { //there was a change, fire fire = true; lastContactTimes[v.Id] = v.LastContactTime; log.Info("last contact time changed, fire observer:{0} at {1}", v.Id, v.LastContactTime); } } else { //new vehicle, fire fire = true; lastContactTimes.Add(v.Id, v.LastContactTime); log.Info("new vehicle, fire observer:{0} at {1}", v.Id, v.LastContactTime); } if (fire) { if (changedAction != null) { changedAction(v); } if (VehicleObservers != null) { foreach (var o in VehicleObservers) { var simpleObserver = o as SimpleObservable <IVehicle>; if (simpleObserver != null) { simpleObserver.Next(v); } } } } } } await Task.Delay(5000); } }
/// <summary> /// Get payment profile information for all your available profiles for the specified service category /// </summary> /// <param name="categoryId">The ID of the category of the service the payment options are used for</param> /// <returns>Response containing the list of payment profile information</returns> static public API.PaymentProfile.GetAvailable.Response GetAvailable(IClient client, int categoryId) => GetAvailable(client, categoryId, null, null, null);
private async Task ExecuteSingle(string line, IClient client) { await Execute(line, client); }
public override async Task <string> ExecuteAsync(IClient client) { //The compiled solidity contract to be deployed //contract test { function multiply(uint a) returns(uint d) { return a * 7; } } var contractByteCode = "0x606060405260728060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000600782029050606d565b91905056"; //As the input the compiled contract is the Data, together with our address var transactionInput = new TransactionInput(); transactionInput.Data = contractByteCode; transactionInput.From = Settings.GetDefaultAccount(); // retrieve the hash var minerStart = new MinerStart(client); var minerStartResult = await minerStart.SendRequestAsync(); var transactionHash = await new PersonalSignAndSendTransaction(client).SendRequestAsync(transactionInput, Settings.GetDefaultAccountPassword()); //get contract address var ethGetTransactionReceipt = new EthGetTransactionReceipt(client); TransactionReceipt receipt = null; //wait for the contract to be mined to the address while (receipt == null) { await Task.Delay(1000); receipt = await ethGetTransactionReceipt.SendRequestAsync(transactionHash); } var minerStop = new MinerStop(client); var minerStopResult = await minerStop.SendRequestAsync(); //Encode and build function parameters var function = new FunctionCallEncoder(); //Input the function method Sha3Encoded (4 bytes) var sha3Signature = "c6888fa1"; //Define input parameters var inputParameters = new[] { new Parameter("uint", "a") }; //encode the function call (function + parameter input) //using 69 as the input var functionCall = function.EncodeRequest(sha3Signature, inputParameters, 69); //reuse the transaction input, (just the address) //the destination address is the contract address transactionInput.To = receipt.ContractAddress; //use as data the function call transactionInput.Data = functionCall; // rpc method to do the call var ethCall = new EthCall(client); // call and get the result var resultFunction = await ethCall.SendRequestAsync(transactionInput); // decode the output var functionDecoder = new FunctionCallDecoder(); var output = functionDecoder.DecodeOutput <int>(resultFunction, new Parameter("uint", "d")); var message = "The result of deploying a contract and calling a function to multiply 7 by 69 is: " + output + " and should be 483"; Assert.Equal(483, output); return(message); }
public WebSocketUserStatusTest() { _client = ClientUtil.FromSettingsFile(); }
public ServerPresetCmdImpl(IClient client) { this.client = client; }
/// <summary> /// Get payment profile information for all your available profiles for the specified service category /// </summary> /// <param name="categoryId">The ID of the category of the service the payment options are used for</param> /// <param name="programId">ID of the program for which the payment options are used. (Only available if the program option is enabled!)</param> /// <param name="paymentMethodId">Payment Method ID</param> /// <returns>Response containing the list of payment profile information</returns> static public API.PaymentProfile.GetAvailable.Response GetAvailable(IClient client, int categoryId, int?programId, int?paymentMethodId) => GetAvailable(client, categoryId, programId, paymentMethodId, null);
private static Action<NumericRangeFacetRequest> NumericRangfeFacetRequestAction(IClient searchClient, string fieldName, double from, double to, Type type) { var range = new List<NumericRange> { new NumericRange(from, to) }; return NumericRangfeFacetRequestAction(searchClient, fieldName, range, type); }
public BillboardService(IClient client) : base(client) { }
public static string GetFullFieldName(this IClient searchClient, string fieldName) => GetFullFieldName(searchClient, fieldName, typeof(string));
public TransientGuildInvite(IClient client, InviteJsonModel model) : base(client, model) { }
/// <summary> /// Initializes a new instance of the <see cref="PostDAL"/> class. /// </summary> /// <param name="iLogger">The i logger.</param> /// <param name="iClient">The i client.</param> public PostDAL(ILogger iLogger, IClient iClient) { _iLogger = iLogger; _iClient = iClient; }
private static Action<NumericRangeFacetRequest> NumericRangfeFacetRequestAction(IClient searchClient, string fieldName, IEnumerable<NumericRange> range, Type type) { var fullFieldName = GetFullFieldName(searchClient, fieldName, type); return x => { x.Field = fullFieldName; x.Ranges.AddRange(range); }; }
public override void SendEvent(IClient client, in EntityCreateEvent entityCreate)
public static CoreUser From(IClient client, User user) { return(new CoreUser(client, ulong.Parse(user.Id), user.Bot, user.Username, user.Discriminator, user.Avatar)); }
public ParityNetPort(IClient client) : base(client, ApiMethods.parity_netPort.ToString()) { }
/// <summary> /// Author says something to a particular client in the chat room. /// </summary> static void SayTo(IClient client, string message) { client.SendMyChatMessagesInform(Resources.Author, message); }
public static void Command(IClient client, String command, IClient target, String args) { if (command == "help") { Help(client); return; } if (!client.Captcha) { if (!command.StartsWith("login ")) { return; } } if (!client.Registered) { if (command.StartsWith("register ")) { AccountManager.Register(client, command.Substring(9)); return; } else if (command.StartsWith("login ")) { AccountManager.Login(client, command.Substring(6)); return; } } else { if (command == "unregister" && !client.Owner) { AccountManager.Unregister(client); return; } if (command == "logout" || command == "logoff") { AccountManager.Logout(client); return; } if (command.StartsWith("nick ")) { if (!Helpers.NameAvailable(client, command.Substring(5)) || command.Substring(5).Length < 2) { return; } if (Nick(client, command.Substring(5))) { client.Name = command.Substring(5); } return; } if (command.StartsWith("setlevel ")) { if (target != null && client.Owner) { if (target.Registered) { byte level; if (byte.TryParse(args, out level)) { if (level <= 3) { target.Level = (ILevel)level; AccountManager.UpdateAccount(client, target); } } } } return; } if (command == "idle" || command == "idles") { if (!IdleManager.CheckIfCanIdle(client)) { return; } IdleManager.Add(client); Events.Idled(client); return; } } if (target != null) { if (target.IUser.Link.IsLinked) { if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready && client.Level > ILevel.Regular) { ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafAdmin(ServerCore.Linker, client, command, target, args)); } return; } } if (DefaultCommands) { cmds.Command(client != null ? client.IUser : null, command, target != null ? target.IUser : null, args); } js.Command(client != null ? client.IUser : null, command, target != null ? target.IUser : null, args); ExtensionManager.Plugins.ForEach(x => { try { x.Plugin.Command(client != null ? client.IUser : null, command, target != null ? target.IUser : null, args); } catch { } }); }
public void Encode(object data, IClient client, Stream stream) { Request request = (Request)data; request.Execute(stream.ToPipeStream()); }
public override void init() { base.init(); registerHeartbeatListener((s, a) => { string heartbeat = Encoding.UTF8.GetString(a.Message.Data, 0, a.Message.Data.Length); var found_list = _clients.Where((participant) => participant.id.Equals(heartbeat)).ToList(); //we dont have a client for the heartbeat we just saw //so create one if (found_list.Count == 0) { IClient client; //create a client for this participant and add to list client = new Client(heartbeat, Role.None, ECOMMS_Entity.Type.None); client.connect(server); client.init(); //use this base client to find out the role of the client that //just connected //if its an instrument then create an instrument client //and add it //if we have a factory instance then use it otherwise //create a base class entity _clients.Add(client); client.addObserver(new ObserverAdapter((o, h) => { switch(h as string) { case "INITIALIZED": if (client.role == Role.Instrument && _clientFactory == null) { var instrumentClient = new InstrumentClient(heartbeat, client.type); instrumentClient.connect(server); instrumentClient.init(); client = instrumentClient; } else if (_clientFactory != null) { IClient tempClient = _clientFactory.getClientFor(heartbeat, client.role, client.type, SubType.None); if (tempClient != null) { tempClient.connect(server); tempClient.init(); client = tempClient; } } notify("CLIENTS_CHANGED"); notify("CONNECTED", client); break; case "ONLINE_CHANGED": if (!client.online) { _clients.Remove(client); notify("CLIENTS_CHANGED"); client.removeAllObservers(); client.removeAllListeners(); } break; } })); } }); }
public EthSendTransaction(IClient client) : base(client, ApiMethods.eth_sendTransaction.ToString()) { }
public abstract void RemoveClient(IClient client);
public EthCoinBase(IClient client) : base(client, ApiMethods.cfx_coinbase.ToString()) { }