private static MockHttpClient<object> PerformGenericApiRequest(Action<HttpChannel> action) { var client = new MockHttpClient<object>(HttpStatusCode.OK); var channel = new HttpChannel(TestContext.Configuration, client); action(channel); return client; }
internal Client(HttpChannel channel, string token, string connectUserId) { channel.SetToken(token); _channel = channel; _token = token; _connectUserId = connectUserId; }
static int Main () { receivedMsg = new AutoResetEvent (false); HttpChannel channel = new HttpChannel (0); #if NET_2_0 ChannelServices.RegisterChannel (channel, false); #else ChannelServices.RegisterChannel (channel); #endif ServerTalk _ServerTalk = (ServerTalk) Activator.GetObject (typeof (ServerTalk), "http://localhost:8081/hydraplus.soap"); CallbackSink _CallbackSink = new CallbackSink (); _CallbackSink.OnHostToClient += new delCommsInfo (CallbackSink_OnHostToClient); _ServerTalk.RegisterHostToClient ("Me", 0, new delCommsInfo (_CallbackSink.HandleToClient)); string messageSent = Guid.NewGuid ().ToString (); _ServerTalk.SendMessageToServer (new CommsInfo ("Me", "txt", messageSent)); if (receivedMsg.WaitOne (5000, false)) { Assert.AreEqual (messageReceived, messageSent, "#1"); return 0; } else { return 1; } }
private void InitialiseClients() { HttpChannel = new HttpChannel(_dataClientConfiguration, _httpClient); _payment = new PaymentsApi(HttpChannel); _pages = new PagesApi(HttpChannel); _customCodes = new CustomCodesApi(HttpChannel); }
static int Main () { SoapServerFormatterSinkProvider serverFormatter = new SoapServerFormatterSinkProvider (); serverFormatter.TypeFilterLevel = TypeFilterLevel.Full; Hashtable ht = new Hashtable (); ht ["name"] = "hydraplus"; ht ["port"] = 8081; ht ["authorizedGroup"] = "everyone"; HttpChannel channel = new HttpChannel (ht, null, serverFormatter); #if NET_2_0 ChannelServices.RegisterChannel (channel, false); #else ChannelServices.RegisterChannel (channel); #endif WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry ( typeof (ServerTalk), "hydraplus.soap", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType (entry); ServerTalk.NewUser = new delUserInfo (NewClient); ServerTalk.DelUser = new delRemoveUser (RemoveClient); ServerTalk.ClientToHost = new delCommsInfo (ClientToHost); clientConnected = new AutoResetEvent (false); clientDisconnected = new AutoResetEvent (false); // wait for client to connect if (!clientConnected.WaitOne (20000, false)) { ReportFailure ("No client connected in time."); return 1; } // wait for message to arrive while (true) { Thread.Sleep (50); if (ServerTalk.ClientToServerQueue.Count > 0) { CommsInfo info = (CommsInfo) ServerTalk.ClientToServerQueue.Dequeue (); ClientToHost (info); break; } } // send message to client ServerTalk.RaiseHostToClient (client.Id, "txt", receivedMsg); // wait for client to disconnect if (clientConnected.WaitOne (2000, false)) { ReportFailure ("Client did not disconnect in time."); return 2; } return 0; }
protected DataApiClientBase(HttpChannel channel) : base(channel) { if (channel.ClientConfiguration == null) { DataClientConfiguration = new DataClientConfiguration(); } else { DataClientConfiguration = channel.ClientConfiguration as DataClientConfiguration; } }
public void InitApis(IHttpClient httpClient, ClientConfiguration clientConfiguration) { HttpChannel = new HttpChannel(clientConfiguration, httpClient); Account = Account ?? new AccountApi(HttpChannel); Donation = Donation ?? new DonationApi(HttpChannel); Page = Page ?? new PageApi(HttpChannel); Search = Search ?? new SearchApi(HttpChannel); Charity = Charity ?? new CharityApi(HttpChannel); Event = Event ?? new EventApi(HttpChannel); Team = Team ?? new TeamApi(HttpChannel); }
static void Main(string[] args) { IDictionary props = new Hashtable(); props["name"] = "MyHttpChannel"; props["port"] = 1090; HttpChannel channel = new HttpChannel( props, new XmlRpcClientFormatterSinkProvider(), new XmlRpcServerFormatterSinkProvider()); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(HelloWorldServer), "xml-rpc-example/xmlrpc", WellKnownObjectMode.Singleton); }
static void Main(string[] args) { bool bUseSoap = false; if (args.Length > 0 && args[0] == "SOAP") bUseSoap = true; HttpChannel chnl; if (bUseSoap) chnl = new HttpChannel(); else chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null); ChannelServices.RegisterChannel(chnl, false); IStateName svr = (IStateName)Activator.GetObject( typeof(IStateName), "http://localhost:5678/statename.rem"); // probably different URL for IIS // IStateName svr = (IStateName)Activator.GetObject( // typeof(IStateName), "http://localhost/statename/statename.rem"); while (true) { Console.Write("Enter statenumber: "); string s = Console.ReadLine(); if (s == "") break; int stateNumber; try { stateNumber = Convert.ToInt32(s); } catch(Exception) { Console.WriteLine("Invalid state number"); continue; } try { string ret = svr.GetStateName(stateNumber); Console.WriteLine("State name is {0}", ret); } catch (XmlRpcFaultException fex) { Console.WriteLine("Fault response: {0} {1} {2}", fex.FaultCode, fex.FaultString, fex.Message); } } }
static void Main(string[] args) { IDictionary props = new Hashtable(); props["name"] = "MyHttpChannel"; props["port"] = 5678; HttpChannel channel = new HttpChannel( props, null, new XmlRpcServerFormatterSinkProvider() ); ChannelServices.RegisterChannel(channel, false); //RemotingConfiguration.Configure("StateNameServer.exe.config", false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(StateNameServer), "statename.rem", WellKnownObjectMode.Singleton); Console.WriteLine("Press <ENTER> to shutdown"); Console.ReadLine(); }
static void RunServer() { IDictionary props = new Hashtable(); props["port"] = 8888; IChannel aChannel = new HttpChannel(props, null, new XmlRpcServerFormatterSinkProvider()); ChannelServices.RegisterChannel(aChannel, false); //InstanceServer myremobj = new InstanceServer(); //RemotingServices.Marshal(myremobj, "statename.rem"); RemotingConfiguration.RegisterActivatedServiceType(typeof(InstanceServer)); RemotingConfiguration.RegisterWellKnownServiceType( typeof(InstanceServer), "statename.rem", WellKnownObjectMode.SingleCall); Console.WriteLine("Press <ENTER> to shutdown"); Console.ReadLine(); }
protected void editAgency_Click(object sender, EventArgs e) { HttpChannel chnl = new HttpChannel(); try { ChannelServices.RegisterChannel(chnl, false); } catch (RemotingException ex) { //all good, nobody cares, but we log it } mgr = (INewsManager)Activator.GetObject(typeof(INewsManager), "http://localhost:1234/NewsManager.soap"); Agency agencyObj = new Agency(); agencyObj.id = Convert.ToInt32(hiddenID.Value); agencyObj.city = CityTxt.Text; agencyObj.language = LanguageTxt.Text; mgr.updateAgency(agencyObj); Agency[] Array_L = mgr.getAgencies(); DataTable dt = new DataTable(); dt.Columns.Add("AgencyID"); dt.Columns.Add("City"); dt.Columns.Add("Language"); for (int i = 0; i < Array_L.Count(); i++) { dt.Rows.Add(); dt.Rows[i]["AgencyID"] = Array_L[i].id.ToString(); dt.Rows[i]["City"] = Array_L[i].city.ToString(); dt.Rows[i]["Language"] = Array_L[i].language.ToString(); } GridView1.DataSource = dt; GridView1.DataBind(); }
public ActionResult Verify_retrieveusers_case(RetrieveUsers_case_Data ret) { ViewBag.check = true; HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); client = (ITwitterSentimentService.ITwitterSentimentService)Activator.GetObject (typeof(ITwitterSentimentService.ITwitterSentimentService), "http://localhost:8080/RetrieveUsers_case"); ArrayList user_retrieve = client.RetrieveUsers_case(ret.case_id); if (user_retrieve != null) { ViewBag.users = user_retrieve; } else { ViewBag.users = null; } ChannelServices.UnregisterChannel(channel); return(View("RetrieveUsers_case")); }
static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); IMyRemoteObject obj = (IMyRemoteObject)Activator.GetObject( typeof(IMyRemoteObject), "http://localhost:1234/MyRemoteObject.soap"); Console.WriteLine("Client.Main(): Reference to rem.obj. acquired"); Console.WriteLine("Client.Main(): Will call setValue(42)"); try { obj.SetValue(42); Console.WriteLine("Client.Main(): Value successfully set."); } catch (Exception e) { Console.WriteLine("Client.Main(): EXCEPTION.\n{0}", e.Message); } // wait for keypress Console.ReadLine(); }
public ActivationServer() { TcpPort = NetworkHelpers.FindFreePort(); HttpPort = NetworkHelpers.FindFreePort(); IDictionary tcpProps = new Hashtable(); IDictionary httpProps = new Hashtable(); tcpProps ["port"] = TcpPort; tcpProps ["bindTo"] = "127.0.0.1"; httpProps ["port"] = HttpPort; httpProps ["bindTo"] = "127.0.0.1"; tcp = new TcpChannel(tcpProps, null, null); http = new HttpChannel(httpProps, null, null); ChannelServices.RegisterChannel(tcp); ChannelServices.RegisterChannel(http); RemotingConfiguration.RegisterActivatedServiceType(typeof(CaObject1)); RemotingConfiguration.RegisterActivatedServiceType(typeof(CaObject2)); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WkObjectSinglecall1), "wkoSingleCall1", WellKnownObjectMode.SingleCall); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WkObjectSingleton1), "wkoSingleton1", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WkObjectSinglecall2), "wkoSingleCall2", WellKnownObjectMode.SingleCall); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WkObjectSingleton2), "wkoSingleton2", WellKnownObjectMode.Singleton); }
static void Main(string[] args) { //WCF、.Net Remoting和WebService的关系: // .Net Remoting是普通的TCP通讯,适合于局域网,效率高; // WebService是基于Http协议,适合于广域网,效率低; //WCF是对.Net Remoting、 WebService等的简化、统一,可以通过配置来切换不同的底层实现,代码几乎不用动。 //本例子是。net remoting Console.WriteLine("创建HTTP通道"); /*创建HTTP通道*/ HttpChannel channel = new HttpChannel(816); /*注册通道服务端*/ ChannelServices.RegisterChannel(channel, false); /*服务端注册,使用Singletong激活*/ RemotingConfiguration.RegisterWellKnownServiceType(typeof(MessageMarshal.TestMessageMarshal), "TestMessageMarshal", WellKnownObjectMode.Singleton); /*接收客户端事件*/ MessageMarshal.TestMessageMarshal.SendMessageEvent += new MessageMarshal.SendMessageHandler(TestMessageMarshal_SendMessageEvent); MessageMarshal.TestMessageMarshal.sendmsg += new MessageMarshal.SendMsg(SendMsg); Console.Read(); }
public static void Main() { // The following sample uses an HttpChannel constructor // to create a new HttpChannel that will listen on port 9000. // System.Runtime.Remoting.Channels.Http.HttpChannel.HttpChannel(IDictionary, IClientChannelSinkProvider, IServerChannelSinkProvider); // <Snippet4> ListDictionary channelProperties = new ListDictionary(); channelProperties.Add("port", 9000); HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider()); ChannelServices.RegisterChannel(channel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleService), "MySampleService/SampleService.soap", WellKnownObjectMode.Singleton); Console.WriteLine("** Press enter to end the server process. **"); Console.ReadLine(); // </Snippet4> }
public static void Start(int port) { try { IDictionary props = new Hashtable(); props["name"] = "MyHttpChannel"; props["port"] = port; _channel = new HttpChannel( props, null, new XmlRpcServerFormatterSinkProvider() ); ChannelServices.RegisterChannel(_channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(StateNameServer), "statename.rem", WellKnownObjectMode.Singleton); } catch (Exception ex) { Console.WriteLine(ex); throw; } }
public static void Main(string[] args) { string[] vs = args[0].Split( new[] { "'" }, StringSplitOptions.None); String id = vs[0]; String URL = vs[1]; int maxFaults = Int32.Parse(vs[2]); int minDelay = Int32.Parse(vs[3]); int maxDelay = Int32.Parse(vs[4]); Uri myUri = new Uri(URL); TcpChannel channel = new TcpChannel(myUri.Port); ChannelServices.RegisterChannel(channel, false); SchedulingServer server = new SchedulingServer(id, URL, maxFaults, minDelay, maxDelay); ServerCli mo = new ServerCli(server); //RemotingServices.Marshal(mo, "mcm", typeof(ServerCli)); RemotingServices.Marshal(mo, myUri.Segments[1], typeof(ServerCli)); HttpChannel channel1 = new HttpChannel(myUri.Port + 200); ChannelServices.RegisterChannel(channel1, false); PuppetServer ps = new PuppetServer(mo); //testing this RemotingServices.Marshal(ps, "ps", typeof(PuppetServer)); // testing this Console.WriteLine("Server " + id + " started on Port " + myUri.Port); System.Console.ReadLine(); }
// Disconnect as from the server and remove client as listener public void DisconnectServer() { if (IsConnected && (Player != null)) { // Remove the player from the game room gameRoom.Leave(Player); } if (channel != null) { ChannelDataStore cds = (ChannelDataStore)channel.ChannelData; foreach (string s in cds.ChannelUris) { channel.StopListening(s); } ChannelServices.UnregisterChannel(channel); } gameRoom = null; Player = null; channel = null; }
static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); IRemoteObject obj = (IRemoteObject)Activator.GetObject( typeof(IRemoteObject), "http://localhost:1234/MyRemoteObject.soap"); Console.WriteLine("Client.Main(): Reference to rem.obj. on " + "Server [1] acquired"); Console.WriteLine("Client.Main(): Will set value to 42"); obj.SetValue(42); int tmp = obj.GetValue(); Console.WriteLine("Client.Main(): New server side value {0}", tmp); IWorkerObject workerobj = (IWorkerObject)Activator.GetObject( typeof(IWorkerObject), "http://localhost:1235/MyWorkerObject.soap"); Console.WriteLine("Client.Main(): Reference to rem. workerobj. on " + "Server [2] acquired"); Console.WriteLine("Client.Main(): Will now call method on Srv [2]"); workerobj.DoSomething(obj); tmp = obj.GetValue(); Console.WriteLine("Client.Main(): New server side value {0}", tmp); Console.ReadLine(); }
static void Main(string[] args) { //IpcChannel channel = new IpcChannel("myhost"); //ChannelServices.RegisterChannel(channel, false); //RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingObjects.Person), "RemotingPersonService", WellKnownObjectMode.SingleCall); HttpChannel httpChannel = new HttpChannel(9001); ChannelServices.RegisterChannel(httpChannel, false); TcpChannel tcpChannel = new TcpChannel(9002); ChannelServices.RegisterChannel(tcpChannel, false); IpcChannel ipcChannel = new IpcChannel("MyHost"); ChannelServices.RegisterChannel(ipcChannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingObjects.Person), "RemotingPersonService", WellKnownObjectMode.SingleCall); Console.ReadLine(); System.Console.WriteLine("Server:Press Enter key to exit"); System.Console.ReadLine(); }
protected void search_Click(object sender, EventArgs e) { papershare showpap = new papershare(); int p = int.Parse(searchtxt.Text); HttpChannel chn4 = new HttpChannel(); ChannelServices.RegisterChannel(chn4, false); Ipaperservice serve = (Ipaperservice)Activator.GetObject(typeof(Ipaperservice), "http://localhost:1234/papmanger.soap"); showpap = serve.retrivepaper(p); txtPJtitle.Text = showpap.JTitle; txtPabstract.Text = showpap.PAbstract; txtPauthers.Text = showpap.Pauther; txtin.Text = Convert.ToString(showpap.PInumber); txtkeywords.Text = showpap.PKeywords; txtPnunmerofauthers.Text = Convert.ToString(showpap.PNofauthers); txtpj2.Text = Convert.ToString(showpap.PPagesF); txtpj1.Text = Convert.ToString(showpap.PPagesN); txtPtitle.Text = showpap.PTitle; txtvn.Text = Convert.ToString(showpap.PVnumber); txtYearofpublishing.Text = Convert.ToString(showpap.PYear); paperresult.Visible = true; errorresult.Visible = true; ChannelServices.UnregisterChannel(chn4); }
static void Main(string[] args) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); Console.WriteLine("Client.Main(): Creating factory"); IRemoteFactory fact = (IRemoteFactory)Activator.GetObject( typeof(IRemoteFactory), "http://localhost:1234/factory.soap"); Console.WriteLine("Client.Main(): Acquiring first object from factory"); IRemoteObject obj1 = fact.getNewInstance(); obj1.setValue(42); Console.WriteLine("Client.Main(): Acquiring second object from factory"); IRemoteObject obj2 = fact.getNewInstance(4711); Console.WriteLine("Obj1.getValue(): {0}", obj1.getValue()); Console.WriteLine("Obj2.getValue(): {0}", obj2.getValue()); Console.ReadLine(); }
public ActionResult Verify_Login(Users_Data user_data) { HttpChannel channel = new HttpChannel(); ChannelServices.RegisterChannel(channel); client = (ITwitterSentimentService.ITwitterSentimentService)Activator.GetObject (typeof(ITwitterSentimentService.ITwitterSentimentService), "http://localhost:8080/CheckUser"); string check_user = client.CheckUser(user_data.first_name, user_data.last_name); if (check_user == "Registered") { ChannelServices.UnregisterChannel(channel); int check = 1; return(this.Home(user_data, check)); } else { ViewBag.check = 0; ChannelServices.UnregisterChannel(channel); return(View("Login")); } }
internal int RequestConfig( String fileName) { if (!s_configDone) { if (true == File.Exists(fileName)) { try { RemotingConfiguration.Configure(fileName); } catch (Exception e) { // Console.WriteLine("Exception in ConfigRemoting"+ e); throw e; } s_configDone = true; // BUGBUG: temporary HACK to get end-to-end activation // going!! s_chnl = (HttpChannel)ChannelServices.GetChannel("Http"); } } return(0); }
public FundraisingPageSummaries ListAllPages(string email) { var locationFormat = ListAllPagesLocationFormat(email); return(HttpChannel.Get <FundraisingPageSummaries>(locationFormat)); }
public void InterestAsync(Action <AccountApi.InterestResponse> callback) { var resourceEndpoint = InterestResourceEndpoint(); HttpChannel.GetAsync(resourceEndpoint, callback); }
public void ContentRatingHistoryAsync(Action <ContentRatingHistoryResponse> callback) { var resourceEndpoint = ContentRatingHistoryResourceEndpoint(); HttpChannel.GetAsync(resourceEndpoint, callback); }
public ContentRatingHistoryResponse ContentRatingHistory() { var resourceEndpoint = ContentRatingHistoryResourceEndpoint(); return(HttpChannel.PerformRequest <ContentRatingHistoryResponse>("GET", resourceEndpoint)); }
public void SetUp() { _config = new ClientConfiguration(TestContext.ApiLocation, TestContext.ApiKey, TestContext.ApiVersion); _httpChannel = new HttpChannel(_config, new HttpClientWrapper()); _api = new AccountApi(_httpChannel); }
static void Main(string[] args) { Console.WriteLine("Inserir port number"); string port = Console.ReadLine(); string id = "http://localhost:" + port + "/Receptor.soap"; HttpChannel ch = new HttpChannel(Convert.ToInt32(port)); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ClientClass.Client), "Receptor.soap", WellKnownObjectMode.Singleton); IManager manager = (IManager)Activator.GetObject(typeof(IManager), "http://localhost:1234/RemoteManager.soap"); string urlserver = manager.GetRing(); Console.WriteLine("Connected to server" + urlserver); IServer server = (IServer)Activator.GetObject(typeof(IServer), urlserver); bool error = true; while (error) { try { for (int i = 0; i < 100; ++i) { if (i % 2 == 0) { urlserver = manager.GetRing(); Console.WriteLine("Connected to server" + urlserver); server = (IServer)Activator.GetObject(typeof(IServer), urlserver); } server.StorePair(new KeyClass(i + ""), new ValueClass("bruno" + i)); } Thread.Sleep(5000); for (int i = 0; i < 100; ++i) { if (i % 2 == 0) { urlserver = manager.GetRing(); Console.WriteLine("Connected to server" + urlserver); server = (IServer)Activator.GetObject(typeof(IServer), urlserver); } IValue v = server.ReadPair(null, new KeyClass(i + ""), id); if (v != null) { Console.WriteLine(v.Value); } error = false; } Thread.Sleep(5000); for (int i = 0; i < 100; ++i) { if (i % 2 == 0) { urlserver = manager.GetRing(); Console.WriteLine("Connected to server to delete" + urlserver); server = (IServer)Activator.GetObject(typeof(IServer), urlserver); } server.DeletePair(new KeyClass(i + "")); } Console.WriteLine("END"); error = false; } catch (Exception ex) { Console.WriteLine(ex.Message); if (ex is RemotingException || ex is WebException) { manager.RemakeRing(urlserver); urlserver = manager.GetRing(); server = (IServer)Activator.GetObject(typeof(IServer), urlserver); } if (ex is SocketException) { Console.WriteLine("*****NO INTERNET OR CLIENT ALREADY RUNNING*****"); error = false; } } } Console.ReadLine(); }
internal QuickConnect(HttpChannel channel) { _channel = channel; }
public AccountApi(HttpChannel channel):base(channel) { }
/* ========= MAIN METHODS ====== */ public static void Main(string[] args) { IDictionary props = new Hashtable(); props["name"] = "MyHttpChannel"; props["port"] = 1090; HttpChannel channel = new HttpChannel( props, new XmlRpcClientFormatterSinkProvider(), new XmlRpcServerFormatterSinkProvider()); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(CSharpServerImplementation), "xml-rpc-example/xmlrpc", WellKnownObjectMode.Singleton); #region Section 1 // ===========================Section 1: Joining the network================================ try { electionHelper = new ElectionHelper(); //assign my IP myIp = Dns.GetHostEntry(Dns.GetHostName()); myIpAddress = NetworkHelper.GetMyIpAddress(); //join network String myNeighbourIp = ""; Console.WriteLine("=====Connecting to Network====="); Console.WriteLine("Please input neighbor IP address :"); myNeighbourIp = Console.ReadLine(); Console.WriteLine(""); RegisterHandler.joinNetwork(myIpAddress, myNeighbourIp); if (!machines.ContainsValue(myIpAddress)) { Console.WriteLine("Add myself to hashmap"); myPriority = addMachineToMap(myIpAddress); } else { //get priority myPriority = machines.First(x => x.Value == myIpAddress).Key; } //set myself as master if null if (ipMaster == "localhost" || ipMaster == null || ipMaster == string.Empty) { setMaster(myPriority); } Console.WriteLine(classNameLog + "Master IP now " + ipMaster); Console.WriteLine(classNameLog + "Master Key now {0}", machines.First(x => x.Value == ipMaster).Value); Console.WriteLine(classNameLog + "My IP now " + myIpAddress); Console.WriteLine(classNameLog + "My priority now " + myPriority); Console.WriteLine(classNameLog + "Machines now " + machines.Count()); } catch (Exception ex) { Console.WriteLine("{0}", ex.Message); } // ====================================End of Section 1======================================== #endregion #region Section 2 // =============================Section 2: Begin service=========================================== string input; do { input = Console.ReadLine().ToLower(); try { Console.WriteLine("Enter command, or 'exit' to quit: "); switch (input) { case "ip": Console.WriteLine("This machine ip :" + myIpAddress); break; default: Console.WriteLine("Command " + input + " not recognized"); break; } } catch (Exception e) { Console.WriteLine("{0}", e.Message); } } while (input != "exit"); // ================================End of Section 2============================================= #endregion Console.WriteLine("Shutting down server..."); serverShutDown(); }
public CustomCodesApi(HttpChannel channel) : base(channel) { }
protected ApiClientBase(HttpChannel channel) { HttpChannel = channel; }
public SearchApi(HttpChannel channel) : base(channel) { }
public void IsEmailRegisteredAsync(string email, Action <bool> callback) { var locationFormat = IsEmailRegisteredLocationFormat(email); HttpChannel.PerformRawRequestAsync("HEAD", locationFormat, response => callback(ProcessIsEmailRegisteredResponse(response))); }
protected DataApiClientBase(HttpChannel channel, ClientConfiguration clientConfiguration) : base(channel) { DataClientConfiguration = clientConfiguration as DataClientConfiguration; }
static void Main(string[] args) { ClientObject co = new ClientObject(); string myIpAddress = co.GetClientIpAdress(); HttpChannel chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null); ChannelServices.RegisterChannel(chnl, false); _localProxy = XmlRpcHelper.Connect("localhost"); _currentMasterUrl = _localProxy.getIpMaster(myIpAddress); _masterProxy = XmlRpcHelper.Connect(_currentMasterUrl); try { // ====== Begin client input ====== string input; ClientUI clientUi = new ClientUI(); do { clientUi.DisplayMainMenu(myIpAddress); input = Console.ReadLine(); switch (input) { case "1": // Menu 1: Show master hashmap. // localProxy.checkMasterStatus(); XmlRpcStruct masterMap = _masterProxy.getMachines(myIpAddress); Dictionary<int, string> networkHashMap = Helper.ConvertObjToDict(masterMap); Console.WriteLine("The Masternode hashmap"); foreach (KeyValuePair<int, string> networkNode in networkHashMap) { Console.WriteLine("Priority {0} : {1}", networkNode.Key, networkNode.Value); } Console.ReadKey(); break; case "2": // Menu 2: Show local hashmap. // localProxy.checkMasterStatus(); XmlRpcStruct localMap = _localProxy.getMachines(myIpAddress); Dictionary<int, string> localhostHashMap = Helper.ConvertObjToDict(localMap); Console.WriteLine("The localnode hashmap"); foreach (KeyValuePair<int, string> localNode in localhostHashMap) { Console.WriteLine("Priority {0} : {1}", localNode.Key, localNode.Value); } Console.ReadKey(); break; case "3": // Menu 3: Get Master Ip. //localProxy.checkMasterStatus(); string result = _localProxy.getIpMaster(myIpAddress); Console.WriteLine("the masterNode is {0}", result); Console.ReadKey(); break; case "4": //Menu 4: do election. // masterProxy.checkMasterStatus(); Console.WriteLine("Election held!!!"); string newMaster = _localProxy.leaderElection(myIpAddress); //string newMasterIp = localProxy.getIpMaster(ipAddress); Console.WriteLine("The new masternode is {0}", newMaster); Console.ReadKey(); break; case "5": // Menu 5: Ricart Agrawala Exlusion. StartMutualExclusion(false); Console.ReadKey(); break; case "6": // Menu 6: Test Mutual Exclusion. StartMutualExclusion(true); Console.ReadKey(); break; case "0": // exit break; default: Console.WriteLine("Invalid command. Please re-enter the command."); Console.ReadKey(); break; } } while (input != "0"); Console.WriteLine("Ending the client session."); Console.ReadKey(); } catch (XmlRpcFaultException fex) { Console.WriteLine("Fault response {0} {1} {2}", fex.FaultCode, fex.FaultString, fex.Message); Console.ReadLine(); } // ===========End of Client Input================ }
protected override void Request(HttpChannel channel) { var rvm = new RequestViewModel(channel, false); App.Current?.Dispatcher?.BeginInvoke((Action)(() => _MainWindow.RequestList.Add(rvm))); }
public ProjectApi(HttpChannel channel) : base(channel) { }
public void RequestPasswordReminderAsync(string email) { var locationFormat = RequestPasswordReminderLocationFormat(email); HttpChannel.PerformRawRequestAsync("GET", locationFormat, ProcessRequestPasswordReminder); }
// private ObjRef internalRef; public static bool StartRemotingServer() { #if NO try { #endif // EndRemoteChannel(); #if NO BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full; Hashtable ht = new Hashtable(); ht["portName"] = "FingerprintChannel"; ht["name"] = "ipc"; ht["authorizedGroup"] = "Administrators"; // "Everyone"; #endif //Instantiate our server channel. #if HTTP_CHANNEL m_serverChannel = new HttpChannel(); #else // TODO: 重复启动 .exe 这里会抛出异常,要进行警告处理 _serverChannel = new IpcServerChannel( "FingerprintChannel"); // _serverChannel = new IpcServerChannel(ht, provider); #endif //Register the server channel. ChannelServices.RegisterChannel(_serverChannel, false); RemotingConfiguration.ApplicationName = "FingerprintServer"; /* * RemotingConfiguration.RegisterWellKnownServiceType( * typeof(ServerFactory), * "ServerFactory", * WellKnownObjectMode.Singleton); * */ //Register this service type. RemotingConfiguration.RegisterWellKnownServiceType( typeof(FingerprintServer), "FingerprintServer", WellKnownObjectMode.Singleton); #if NO internalRef = RemotingServices.Marshal(this, "FingerprintServer"); #endif Program.FingerPrint.Captured += FingerPrint_Captured; // Program.MainForm.OutputHistory("111"); return(true); #if NO } catch (RemotingException ex) { this.ShowMessage(ex.Message); return(false); } #endif }
internal BigDB(HttpChannel channel) { _channel = channel; }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { // Event log trace EventLogTraceListener traceListener = new EventLogTraceListener(SyslogServiceName); // Add the event log trace listener to the collection. Trace.Listeners.Add(traceListener); if (ssSwitch.TraceInfo) { Trace.WriteLine(SyslogServiceName + " starting", DbTraceListener.catInfo); } try { // Initialize database string connString = Properties.Settings.Default.DbConnection; if (connString == null || connString.Length == 0) { throw new Exception("No database connection string specified"); } // Connect to database - try a few times should database not be up yet int tryCount = 3; bool connected = false; do { try { using (OleDbConnection conn = new OleDbConnection(connString)) { conn.Open(); } connected = true; } catch (Exception ex) { if (ssSwitch.TraceError) { Trace.WriteLine("Could not connect to database: " + ex.Message, DbTraceListener.catError); } // Sleep for 5 seconds then try again Thread.Sleep(5000); tryCount--; } } while (!connected && (tryCount > 0)); if (!connected) { throw new Exception("Could not connect to database"); } // Start database log DatabaseLog.Instance.Initialize(connString); // Load Configuration SyslogConfiguration.Instance.Initialize(connString); // Clear down messages periodically _cleanup = new SyslogMessageCleanup(SyslogConfiguration.Instance.RetentionPeriod); _cleanup.Initialize(connString); // Create server channel int serverPort = Properties.Settings.Default.ServerPort; if (serverPort <= 0) { throw new Exception("Invalid server port specified in configuration file"); } _channel = new HttpChannel(serverPort); ChannelServices.RegisterChannel(_channel, false); // Create shared object _sharedData = new SharedData(); // Marshall object _obj = RemotingServices.Marshal(_sharedData, "SyslogSharedData"); // Register for updates SyslogConfiguration.Instance.ConfigurationChanged += new Configuration.ConfigurationChangedDel(OnConfigurationChanged); } catch (Exception ex) { if (ssSwitch.TraceError) { Trace.WriteLine("Could not initialize: " + ex.Message, DbTraceListener.catError); } // Fatal - stop right now throw; } try { Connect(); } catch (Exception ex) { if (ssSwitch.TraceError) { Trace.WriteLine(String.Format("Could not start to collect syslog messages on port {0}: {1}", SyslogConfiguration.Instance.Port, ex.Message), DbTraceListener.catError); } // Not fatal - probably port is in use - so carry on regardless // Hope for configuration Disconnect(); } }
public EventApi(HttpChannel channel) : base(channel) { }
public AccountDetails RetrieveAccount() { var locationFormat = RetrieveAccountLocationFormat(); return(HttpChannel.PerformRequest <AccountDetails>("GET", locationFormat)); }
public TeamApi(HttpChannel channel) : base(channel) { }
public AccountApi(HttpChannel channel) : base(channel) { }
public SmsApi(HttpChannel channel) : base(channel) { }
public string Create(CreateAccountRequest request) { return(HttpChannel.Put <CreateAccountRequest, AccountRegistrationConfirmation>(ResourceBase, request).Email); }
void Page_Load(object sender, EventArgs e) { if (Session["First"] == null) { Response.Redirect("Default.aspx"); } HttpChannel channel = new HttpChannel(); // ChannelServices.RegisterChannel(channel); //string name1 = (string)(Session["First"]); try { string name1 = (string)(Session["First"]); Label13.Text = name1; Label1.Text = " "; // To find IP address of a machine behind LAN you can use this code string strHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); //Find IP Address Behind Proxy Or Client Machine In ASP.NET IPAdd = string.Empty; IPAdd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(IPAdd)) { IPAdd = Request.ServerVariables["REMOTE_ADDR"]; //Label4.Text = IPAdd; } //literal string mar = "<MARQUEE><strong>"+name1 + " IP is <font color='red'>" + IPAdd + "</Font>. It will be used as your ID</strong></MARQUEE>"; Literal1.Text = mar; string mar2 = "<MARQUEE scrollamount='2'><strong>" + name1 + " IP is <font color='red'>" + IPAdd + "</Font>. It will be used as your ID</MARQUEE></strong>"; Literal2.Text = mar2; string mar3 = "<MARQUEE direction='right'><strong>" + name1 + " IP is <font color='red'>" + IPAdd + "</Font>. It will be used as your ID</MARQUEE></strong>"; Literal3.Text = mar3; string mar4 = "<MARQUEE direction='right' scrollamount='2'><strong>" + name1 + " IP is <font color='red'>" + IPAdd + "</Font>. It will be used as your ID</MARQUEE></strong>"; Literal4.Text = mar4; } catch (Exception ex) { } }
public void CreateAsync(CreateAccountRequest request, Action <string> callback) { HttpChannel.PutAsync <CreateAccountRequest, AccountRegistrationConfirmation>(ResourceBase, request, response => callback(response.Email)); }
public InMemoryApi(HttpChannel channel) : base(channel) { }
public void ListAllPagesAsync(string email, Action <FundraisingPageSummaries> callback) { var locationFormat = ListAllPagesLocationFormat(email); HttpChannel.GetAsync(locationFormat, callback); }
public PagesApi(HttpChannel channel) : base(channel) { }
public CharityApi(HttpChannel channel) : base(channel) { }
protected DataApiClientBase(HttpChannel channel) : base(channel) { _configuration = ConfigurationManager.GetSection("justGivingDataSdk") as JustGivingDataSdkConfiguration; }