[已解决] Server-Sent Events (SSE)該如何實現?

Moderator: ESP_Bob

cye-barry
Posts: 17
Joined: Thu Sep 23, 2021 9:54 am

[已解决] Server-Sent Events (SSE)該如何實現?

Postby cye-barry » Fri Oct 22, 2021 4:02 am

目前使用mit app inventor 來和ESP8266做溝通

剛好在網路上看到有這樣的做法server-sent-events(SSE)
https://randomnerdtutorials.com/esp8266 ... vents-sse/

(1)這種通訊格式要怎麼發送和回覆?

類似這樣↓(發送)
+IPD,0,282:POST /write HTTP/1.1
Content-Type: application/json
Content-Length: 46
User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; HTC_D10u Build/MMB29M)
Host: xxx.255.232.xxx:3310
Connection: Keep-Alive
Accept-Encoding: gzip
{"WR":"An","par":["3320","254","14563","258"]}

類似這樣↓(回覆)
HTTP/1.1 200 OK
Date: Tue, 09 May 2021 01:28:42 GMT
Content-Type:application/json
Content-Length:46
Connection:keep-alive
Server:ESP8266-Micro-Server1.1

{"WR":"An","par":["3320","254","14563","258"]}

要怎麼做修改呢?

(2)不知道能不能問的到,mit app inventor 有提供這種SSE的library麼?
或者用一般web.url就能實現呢?

cye-barry
Posts: 17
Joined: Thu Sep 23, 2021 9:54 am

Re: Server-Sent Events (SSE)該如何實現?

Postby cye-barry » Wed Oct 27, 2021 1:11 am

問題已解決,方法如參考連結
https://github.com/IU5HKU/ESP8266-ServerSentEvents

至於 MIT App Inventor 要解析SSE發送過來的Event,可能需要再寫java外掛吧~

Who is online

Users browsing this forum: No registered users and 12 guests