sockets - How to implement SuperSocket -
i trying implement supersockets - https://supersocket.codeplex.com/ project working on. have server uses configuration run. in project
i have referenced:
supersocket.common, supersocket.socketbase, supersocket.socketengine
i added following config section:
<configsections> <section name="supersocket" type="supersocket.socketengine.configuration.socketserviceconfig, supersocket.socketengine" /> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <appsettings> <add key="servicename" value="someservice" /> </appsettings> <supersocket logfactory="consolelogfactory" disableperformancedatacollector="true" maxworkingthreads="500" maxcompletionportthreads="500" minworkingthreads="5" mincompletionportthreads="5"> <servers> <server name="someservice" servertype="someservice.server.someservice, someservice" ip="192.168.1.107" port="4096" disablesessionsnapshot="true" clearidlesession="false" maxconnectionnumber="10" sendwelcome="false"> </server> </servers> <logfactories> <add name="consolelogfactory" type="supersocket.socketbase.logging.consolelogfactory, supersocket.socketbase" /> </logfactories> </supersocket>
i created server , session class follows:
namespace someservice.server { class someservice: appserver<someservicesession> { protected override bool setup(irootconfig rootconfig, iserverconfig config) { return base.setup(rootconfig, config); } protected override void onstartup() { base.onstarted(); } protected override void onstopped() { base.onstopped(); } } } namespace someservice.server { class someservicesession : appsession<someservicesession> { protected override void onsessionstarted() { // this.send("welcome supersocket telnet server"); } protected override void handleunknownrequest(stringrequestinfo requestinfo) { this.send("unknow request"); } protected override void handleexception(exception e) { this.send("application error: {0}", e.message); } protected override void onsessionclosed(closereason reason) { //add logics executed after session closed base.onsessionclosed(reason); } } }
at point server runs , listens on port intended. here wireshark representation of want supersocket http://imgur.com/rxkjbod. if see on request reply 1 chuck of data :
.msh|^~\&|mri|abc|||201403251406||qry|173883426|p|2.1 qrd|201403251406|r|i|xxxxx|||25^rd|ab851656^|mpi qrf|upi|||| .
is client ,
.msh|^~\&|mri|abc|||201403251406||qry|173883426|p|2.1 qrd|201403251406|r|i|xxxx|||25^rd|ab851656^|mpi qrf|upi|||| msa|aa|173883426 .
is server. response returned varies depending on request , created after business logic executes (but going same format- hl7 en(dot)wikipedia(dot)org/wiki/health_level_7 ). hl7 follows mllp messaging format each message begins start block code (0x0b) , each segment within message terminated carriage return code (0x0d) , each message terminated end block code (0x1c) followed carriage return code (0x0d). once request have business logic class parses out values, calls web service gets data , constructs tcp reply. know in supersocket can have method or event listener read buffer , business logic , return response same session. know there concepts filters , commands in supersocket haven't been able figure them out. appreciated. let me know if need additional detail.
Comments
Post a Comment