private void launchMainForm(ServerServiceClient serverClient) { if (serverClient.State == CommunicationState.Opened) { // Handling user interfaces RegistView mf = new RegistView(serverClient); this.Visible = false; // Running Main form mf.ShowDialog(this); // Restoring Login interface this.Visible = true; loginButton.Enabled = true; // Close connection serverClient.Close(); return; } serverClient.Abort(); var info = new InfoForm(); info.Add("Erro a conectar ao servidor"); info.ShowDialog(this); loginButton.Enabled = true; }
private void launchMainForm(ServerServiceClient serverClient) { if (serverClient.State == CommunicationState.Opened) { // Handling user interfaces RegistView mf = new RegistView(serverClient); this.Visible = false; // Running Main form mf.ShowDialog(this); // Restoring Login interface this.Visible = true; loginButton.Enabled = true; // Close connection serverClient.Close(); return; } serverClient.Abort(); var info = new InfoForm(); info.Add("Erro a conectar ao servidor"); info.ShowDialog(this); loginButton.Enabled = true; }
static void Main(string[] args) { try { ServerServiceClient client = new ServerServiceClient(); var result = client.getHighscoresForLevel("test1"); Console.WriteLine(result.scores.Count()); client.Close(); } catch (Exception e) { Console.WriteLine("Exception thrown: " + e.ToString()); } Console.WriteLine("Press Enter key to exit"); Console.ReadLine(); }
static void Main(string[] args) { var client = new ServerServiceClient("BasicHttpBinding_IServerService", "http://localhost:8000/ServerService"); client.Test("test text"); var sessionName = GetSessionName(); client.StoreSession(sessionName); Console.WriteLine(client.GetSessionName()); client.SendByteData(new byte[100000]); client.SendString(sessionName); Console.WriteLine("Uploaded"); Console.ReadLine(); client.Close(); }
static void Main(string[] args) { //To add ServerServiceClient use //svcutil.exe http://localhost:8000/ServerService?wsdl //OR easier way //To add new right click on project "Add Service Reference" //Update right click on "Service References->ServiceReference1" then "Update Service Reference" ServerServiceClient client = new ServerServiceClient("BasicHttpBinding_IServerService", "http://localhost:8000/ServerService"); var result = client.Test("test text"); Console.WriteLine("Session Name:"); var sessionName = Console.ReadLine(); client.StoreSession(sessionName); Console.WriteLine(client.GetSessionName()); Console.ReadLine(); client.SendByteData(new byte[100000]); Console.WriteLine("Uploaded"); Console.ReadLine(); client.Close(); }
public void OnDestroy() { client.Close(); }
public static void CloseAfariaServiceServer(ServerServiceClient svcServer) { try { if (svcServer != null) { // Get the state of the service System.ServiceModel.CommunicationState commState = svcServer.State; // If the service is faulted, we still need to abort if (commState == System.ServiceModel.CommunicationState.Faulted) { svcServer.Abort(); } // If the state is not already closed or in the process of closing, we should close the context else if (commState != System.ServiceModel.CommunicationState.Closing || commState != System.ServiceModel.CommunicationState.Closed) { // Get the context info to get the context ID, although we saved this in the context string variable Server.ContextInfo contextInfo = svcServer.GetContextInfo(); // Assure that there is a valid context ID if (!string.IsNullOrWhiteSpace(contextInfo.ContextId)) { // Close the context svcServer.CloseContext(); } // Now close the service svcServer.Close(); } // If the channel is closing/closed, attempt to close out the context, but don't need to close state else { // We will likely throw an exception here. svcServer.CloseContext(); } svcServer = null; } } catch (Exception ex) { // Just ouput the exception, proper handling should initiate a new service, initiate the context to the previous, // and then close out the context and service Console.WriteLine(ex.Message.ToString()); logger.Error("Error while closing Server service", ex); } }