Solve the problem of incorrect handling of the SessionID field in PicoMessage
This commit is contained in:
parent
6f5930624b
commit
37d1713247
1 changed files with 6 additions and 1 deletions
|
|
@ -209,7 +209,7 @@ func (c *PicoChannel) broadcastToSession(chatID string, msg PicoMessage) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if pc.sessionID == sessionID {
|
if key == sessionID {
|
||||||
if err := pc.writeJSON(msg); err != nil {
|
if err := pc.writeJSON(msg); err != nil {
|
||||||
logger.DebugCF("pico", "Write to connection failed", map[string]any{
|
logger.DebugCF("pico", "Write to connection failed", map[string]any{
|
||||||
"conn_id": pc.id,
|
"conn_id": pc.id,
|
||||||
|
|
@ -421,6 +421,11 @@ func (c *PicoChannel) handleMessageSend(pc *picoConn, msg PicoMessage) {
|
||||||
sessionID := msg.SessionID
|
sessionID := msg.SessionID
|
||||||
if sessionID == "" {
|
if sessionID == "" {
|
||||||
sessionID = pc.sessionID
|
sessionID = pc.sessionID
|
||||||
|
} else {
|
||||||
|
// Check if sessionID already exists
|
||||||
|
if _, ok := c.connections.Load(sessionID); !ok {
|
||||||
|
c.connections.Store(sessionID, pc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chatID := "pico:" + sessionID
|
chatID := "pico:" + sessionID
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue