Last active
August 22, 2023 06:35
-
-
Save pingkunga/2879c7a2150a6a51859531310c1c652d to your computer and use it in GitHub Desktop.
TCP_JSON#04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InvsRequestHandler : AbstractBaseRequestHandler, IRTRequestHandler | |
{ | |
protected override void run() | |
{ | |
try | |
{ | |
while (true) | |
{ | |
NetworkStream ns = clientSocket.GetStream(); | |
object deserialized =((IFormatter)new BinaryFormatter()).Deserialize((Stream)ns); | |
ParamDTO param = (ParamDTO)deserialized; | |
//Your Business Logic | |
IList<BusinnesLogicDTO> resultls = ProcessSomeLogic(param); | |
//... | |
//Serialize Object and Send Result Back to Client | |
BinaryWriter bw = new BinaryWriter(ns); | |
MemoryStream ms = new MemoryStream(); | |
new BinaryFormatter().Serialize(ms, resultls); | |
bw.Write(ms.ToArray()); | |
bw.Flush(); | |
} | |
} | |
catch (Exception wex) | |
{ | |
clientSocket.Close(); | |
logger.Error(wex.Message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment