Home > Net >  C # websocket data forwarding how to do?
C # websocket data forwarding how to do?

Time:04-13

A JSP client (J), a C # program (C), multiple function of C # program (C01, our fleet... ), we need to send json request to C J, C program for forwarding, judging by the json request is forwarded to C01 or our fleet, C01/our fleet processing is completed, and then returned to C, C continue returned to J, J and currently C01 our fleet... Implemented, but there is no thoughts of C, please forward how to do?

CodePudding user response:

The design of the trouble, it requires you to each end of the first "reservation" data

So you can consider to use mq directly, Kafka, MQTT middleware, such as direct do

Must websockt words, then you can only accept reservations, remember, and then forward

CodePudding user response:

That is to say, your C in the present case, actually don't need to do,

His function is actually existing mq, the function of the MQTT

CodePudding user response:

http://bbs.cskin.net/thread-18391-1-1.html

CodePudding user response:

reference 1st floor wanghui0380 response:
the design of the trouble, it requires you to each end of the first "reservation" data

So you can consider to use mq directly, Kafka, MQTT middleware, such as direct do

Must websockt words, then you can only accept reservations, remember, and then forward


Before there is no C01 and our fleet, etc., are C control access to different types of devices, because there will be some equipment is unusual, lead to C exit, so to do split, C01 access to data to continue (continuous focus) returned to C, at last returned to the J C, send at present: J - C - C01, C01 returned to C, C can also accept, but can't return J,
WebSocket4Net. MessageReceived +=receiveData;//the server after the return data, enter this method (C in this method, the J hair when the hair is not the past)

CodePudding user response:

refer to the second floor wanghui0380 response:
that is to say, your C in the present case, actually don't need to do,

His function is actually existing mq, the function of the MQTT


Before there is no C01 and our fleet, etc., are C control access to different types of devices, because there will be some equipment is unusual, lead to C exit, so to do split, C01 access to data to continue (continuous focus) returned to C, at last returned to the J C, send at present: J - C - C01, C01 returned to C, C can also accept, but can't return J,
WebSocket4Net. MessageReceived +=receiveData;//the server after the return data, enter this method (C in this method, the J hair when the hair is not the past)

CodePudding user response:

reference 5 floor tang448112979 reply:
Quote: refer to the second floor wanghui0380 response:
that is to say, your C in the present case, actually don't need to do,

His function is actually existing mq, the function of the MQTT


Before there is no C01 and our fleet, etc., are C control access to different types of devices, because there will be some equipment is unusual, lead to C exit, so to do split, C01 access to data to continue (continuous focus) returned to C, at last returned to the J C, send at present: J - C - C01, C01 returned to C, C can also accept, but can't return J,
WebSocket4Net. MessageReceived +=receiveData;//the server after the return data, enter this method (C in this method, to J, hair don't past)


Selection of oh, say the MQTT (I'll push the MQTT him, according to your things, MQTT is the most complex, is also relatively simple selection)

JSP: I don't know what look like, this JSP is now nothing people from JSP actual use, but if it is HTML side push, js maqqjs finished-product stock, integration does not need 30 minutes, if the backend is Java MQTT library, also will not exceed 30 minutes integration

I give a example of request

JSP side
reference
topic: Command/C01/Request
Content: {" parameters ":" XXXXXX "}
The rebound, there is also a topic: the Command/C01/reponse/guid//this guid is a serial number, used to distinguish different time order

Subscription. The Command/C01/reponse/guid. Subscription (p=& gt; Unsubscribe)
Release the above referenced part


C side without you, your side can completely remove



Your C1 end

MQTT startup connection, at the same time to subscribe to the Command/C01/Request
And then processed, send the results to the organiser of the topic in the packet data

You other C2 and C3, Cn side like C1 end processing, just subscribe to the topic of different, C2 is subscribe Command/our fleet/Request

CodePudding user response:

A free version of MQTT broke

Emqx

Download and install don't need you half an hour, you only need to install this, you can achieve your C server-side functionality

CodePudding user response:

From your reply, you actually say because will crash all adopt multiple processes, is actually multi-process communication, in order to simplify the process, you can directly use the actual process of communication, need not what websocket transit, consult the MQTT upstairs because of you, you will find that if you must use a websocket in transit, they you have to show his identity

I know, for example, the websocket in C1, C2 is this.
So you see, the MQTT use to subscribe to this step to deal with, C1 subscribe to news of C1, so we know C1 instruction for C1 client

So if the simplified communication, you can directly use process communications, such as a named pipe, I open a named pipe "IPC/comand/C1" we use this pipe communication

Or GRPC different ports, such as "TCP: 80001" C01, so he is naturally separated, don't need you forward, you only need to do GRPC request
  •  Tags:  
  • C#
  • Related