0

I'm setting up a new client-server-network with SuperSocket and can't connenct an AppSession to the server.

I found this question and tried it for my program.

The server is running fine, but at the moment I can only connect with the 'AsynTcpSession'. When I check the connected sessions it is shown as an 'AppSession' at the server. I want to use 'AppSession', because you can give them custom parameter.

My created AppSession:

public class MyAppSession : AppSession<MyAppSession, MyRequestInfo>
{
// those parameter
public int ClientKey { get; set; }

public string HashKey { get; set; }
}

Server:

MyAppServer _server = new MyAppServer();
ServerConfig _socketServerConfig = new ServerConfig { ReceiveBufferSize = 5000, MaxRequestLength = 5000, Name = "Test- Server", SendingQueueSize = 5000, ServerType = "MyAppServer", Port = 6000};

if (_server.Setup(_socketServerConfig))
{
DoStuff();
}

Client:

ClientSession _gateway = new AsyncTcpSession();
_gateway.Connect(6000);

On receiving telegram from Client:

private void ReceivedDataFromClient(MyAppSession session, MyRequestInfo requestinfo)
{
// session.SocketSession contains the Client AsynTcpSession
}

EDIT:

The AppSession has an void Initialize(IAppServer<TAppSession, TRequestInfo> appServer, ISocketSession socketSession)-Function. How do I use it? The session only knows the server ip and port.

Boeckle
  • 13
  • 7
  • Why don't you want to use AsynTcpSession. I wouldn't attempt to change the asynchronous method to synchronous. – jdweng Jul 22 '19 at 13:14
  • The 'NewSessionConnected'-event transforms the new session to an 'AppSession'. The 'AsynTcpSession' is now a part of the 'AppSession' `newSession.SocketSession`. I was wondering if you can connect an 'AppSession' as client, because you can hand over custom parameters. – Boeckle Jul 22 '19 at 13:36
  • Not from the same PC with same port number. You can only have one connection with the same three parameters 1) Source IP address 2) Destination IP address 3) Port number. So adding a new session from the same PC would not work. A server/listener can support more than one connection from different IP addresses, but not one that would create duplicate connection parameters. – jdweng Jul 22 '19 at 13:41
  • I don't want to add connection parameters, more like additionally information about the clients, which are passed to the server when connecting. – Boeckle Jul 22 '19 at 13:56
  • See documentation : http://docs.supersocket.net/v2-0/en-US/Command-and-Command-Loader – jdweng Jul 22 '19 at 14:14
  • you can create your own AppSession - add your required properties and methods to it. Share some of your code with example of what you are trying to achieve – Dawood Awan Jul 24 '19 at 10:56
  • You will need to pass the parameters from the client to the server, then you can map them to the properties in the MyAppSession – Dawood Awan Jul 25 '19 at 15:01
  • So I have to do it within the telegram I send from the client to the server? Because this is what I'm doing currently. The server will map the received data. – Boeckle Jul 26 '19 at 05:29

1 Answers1

0

AsynTcpSession and AppSession are different things, althought they are all called 'session'.

Any client connection packages / classes have no matter with AppSession. (eg. AsynTcpSession)

The AppSession just a temporary storage of client connection for AppServer. Let the AppServer controlls the client connections, identify each clients, controll the connections pool...etc. You can define many variables in the AppSession, But to assign values will still by your own codes (and client should send these informations).

Chinor
  • 91
  • 1
  • 6
  • I'm allready using this as workaround, but I thought there was a better way for it. Thanks for your share! – Boeckle Aug 21 '19 at 06:57