摘要: 建立连接过程 1.客户端发起握手请求 GET /chat HTTP/1.1Host: example.comUpgrade: websocketConnection: UpgradeSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==Sec-WebSocket-Ve 阅读全文
posted @ 2025-05-29 15:38 CJTARRR 阅读(35) 评论(0) 推荐(0)
摘要: 0.安装依赖 go get github.com/gorilla/websocket 1.服务端 package utils import ( "log" "net/http" "github.com/gorilla/websocket" ) // 从http升级到websocket,这是webso 阅读全文
posted @ 2025-05-29 14:13 CJTARRR 阅读(94) 评论(0) 推荐(0)
摘要: 1.迭代器 class MyIterator: def __init__(self, data): self.data = data self.index = 0 def __iter__(self): return self def __next__(self): if self.index >= 阅读全文
posted @ 2025-05-29 09:53 CJTARRR 阅读(13) 评论(0) 推荐(0)