SignalGo/SignalGo-full-net

Articles in wiki are out of date.

Closed this issue · 3 comments

I'm trying using SignalGo by "Getting Started (rapid develop your first server client infrastructure with SignalGo)" in wiki.
It cannot be rebuilt in any way by it.
look forward to make it work!

@dms-aping thank you for using Signalgo, We are working for microservices architecture by SignalGo, Sorry for that I didn't update Wiki that is important, But I'm always online to answer the issues of developers.
I will make it in the wiki so you can ask me here the problems that you have I will answer you here

check this:

https://github.com/SignalGo/SignalGo-full-net/wiki/Signalgo-server-HelloWorld

SharedSignalGo:
IServerMethods.cs

    [ServiceContract("ServerMethods", ServiceType.ServerService, InstanceType.SingleInstance)]
    public interface IServerMethods
    {
        //methods here will run server side always asyncronously in a separate thread
        string HelloFromServer();
        List<Person> SendList();
    }

IClientMethods.cs

    [ServiceContract("ClientMethods", ServiceType.ClientService, InstanceType.SingleInstance)]
    public interface IClientMethods
    {
        string GetMachineName();
    }

ServerSignalGo:
ServerMethods.cs.

public class ServerMethods : IServerMethods
public string HelloFromServer()
{
    return "HelloFromServer";
}
        public List<Person> SendList()
        {
            List<Person> list_persons = new List<Person>();
            for (int i = 0; i < 5; i++)
            {
                Person pr = new Person
                {
                    Name = "Name_" + i,
                    Surname = "Surname_" + i,
                    Address = "Adress_" + i,
                    Age = i,
                };
                list_persons.Add(pr);
            }
            return list_persons;
        }

frmMain.cs

        private void BtnStartServer_Click(object sender, EventArgs e)
        {
            try
            {
                //no need to start the server if it's already running
                if (this.server.IsStarted == true)
                {
                    return;
                }
                else
                {
                    //initialize the service registering methods that can be executed on server by clients
                    server.RegisterServerService<ServerMethods>();
                    richtextbox_server.AppendText("Server starting..." + Environment.NewLine);
                    //we start the server
                    server.Start("http://192.168.2.127:8080/AppSignalGo");
                    //set up some settings
                    server.ProviderSetting = new SignalGo.Shared.Models.ProviderSetting() { IsEnabledDataExchanger = true };
                    richtextbox_server.AppendText("Server started " + Environment.NewLine);
                    //register client callback: the methods the server can execute on clients
                    server.RegisterClientService<IClientMethods>();
                    richtextbox_server.AppendText("Waiting for incoming connections" + Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                richtextbox_server.AppendText("Error: " + ex.Message + Environment.NewLine);
            }
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            server.Dispose();//Can't shut down completely
        }

ClientSignalGo:
ClientMethods.cs

    public class ClientMethods : IClientMethods
    {
        public string GetMachineName()
        {
            return System.Environment.MachineName;
        }
    }

frmMain.cs

        private async void BtnConnecttoServer_Click(object sender, EventArgs e)
        {
            
            try
            {
                richTexBoxClient.AppendText("Connecting to Server..." + Environment.NewLine);
                //this action prevent freezing the UI  
                await Task.Run((Action)(() =>
                {
                    connector.Connect(serverAdress);
                }));
                richTexBoxClient.AppendText("Registering services" + Environment.NewLine);
                //register the server callback
                callbacks = connector.RegisterClientService<ClientMethods>();
                //register the interface defining the async methods
                ServerService = connector.RegisterServerService<IServerMethods>();
                richTexBoxClient.AppendText("Services registered" + Environment.NewLine);
                richTexBoxClient.AppendText("Connection esablished with " + serverAdress + " Your ID is " + connector.ClientId + Environment.NewLine);
                //we call the method on server and print it into the richtextbox once received
                var res = ServerService.HelloFromServer();
                richTexBoxClient.AppendText(res + Environment.NewLine);
                //in this action wwe handle OnDisconnected action of this client

            }
            catch (Exception ex)
            {
                richTexBoxClient.AppendText(ex.Message + Environment.NewLine);
            }
        }

1.when BtnConnecttoServer_Click invoked, exception catched:
Constructor on type 'SharedSignalGo.IServerMethods' not found.
2. the server app can't shut down completely!
Thanks!

@dms-aping Ok let's learn something in SignalGo:
1.Don't use ServiceContract attributes over your interfaces on the server-side because you cannot have two services with one route address, so it does not work, please use ServiceContract over your c# class that inheritance your interface, however, in SignalGo architecture you don't need to use interfaces for server services. if you need interfaces for the client-side SignalGo code generator will generate them for you easily from your service classes by the server-side see here:

https://github.com/SignalGo/SignalGo-full-net/wiki/Add-Service-Reference---Auto-generate-all-services-and-models-in-client-side

and here:
https://github.com/SignalGo/SignalGo-full-net/wiki/Visual-Studio-Extension-%28VSIX%29---Code-Generator

2.for the server-side we always using console application that is very easy to manage server projects, but if you want to have windows forms project best practice is starting the server in your startup of windows forms or console app.