hikalkan / scs

TCP Server/Client Communication and RMI Framework
MIT License
225 stars 112 forks source link

Get ServiceObject back on connection #27

Closed kedrin closed 7 years ago

kedrin commented 7 years ago

When using ScsServiceBuilder, is there a way to get the service type back on client connection? I am trying to get what service was connected to returned during the ClientConnected event.

For instance the client connecting to server.AddService<IPhoneBookService, PhoneBookService>(new PhoneBookService());

The connection evernt should also return they type PhoneBookService's type name

hikalkan commented 7 years ago

Hi,

Server can define more than one service in a single endpoint. There is no way to get service type in the client. It's expected that your client code already knows the service type it will use.

kedrin commented 7 years ago

No i need to know which service type is being connected to on the server side.

say IPhoneBookService1 and IPhoneBookService2 service trigger the same connection event, how do i know which service is doing it?

hikalkan commented 7 years ago

When a client connects to an endpoint that has more than one service, the client connects them in the same time. So, you don't need to know the service, because connection is independent from services.

kedrin commented 7 years ago

Yea, i gathered that after digging through the code, I was just hoping there was a way to know which service was being going to be used before hand on the connection event. It explains why what I had modified returned all services during the connection. Thanks anyway.