-
Notifications
You must be signed in to change notification settings - Fork 14
Service Providers (Server Side Example)
Ali Yousefi edited this page Mar 24, 2018
·
5 revisions
After you learn it ServiceContractAttribute you can create your simple Service with this attribute.
for example we have an interface that is our sevice level methods.
[SignalGo.Shared.DataTypes.ServiceContract("TestServerModel", ServiceType.ServerService, InstanceType = SignalGo.Shared.DataTypes.InstanceType.SingleInstance)]
public interface ITestServerModel
{
Tuple<string> HelloWorld(string yourName);
}
public class TestServerModel : ITestServerModel
{
public Tuple<string> HelloWorld(string yourName)
{
return new Tuple<string>("hello: " + yourName);
}
}
After create your service classes you must start your service listener in your Main method console project or your windows service project or ...
for example:
static void Main(string[] args)
{
// create instance of your server listener
SignalGo.Server.ServiceManager.ServerProvider server = new SignalGo.Server.ServiceManager.ServerProvider();
//register your service class that have implemented methods (not interfaces)
server.RegisterServerService<TestServerModel>();
//start your server provider (your server address is important for client to connect)
server.Start("http://localhost:1132/SignalGoTestService");
//this code hold windows close and don't let him to close after read one line this will be close.
Console.ReadLine();
}