mirror of
https://github.com/raz-varren/sacrificial-socket.git
synced 2025-10-20 14:55:14 +08:00
map[string]interface{} does not cover all possible json data types
This commit is contained in:
@@ -80,7 +80,7 @@ func (p *propagateServer) DoBroadcast(ctx context.Context, b *transport.Broadcas
|
|||||||
|
|
||||||
switch b.DataType {
|
switch b.DataType {
|
||||||
case transport.DataType_JSON:
|
case transport.DataType_JSON:
|
||||||
d := make(map[string]interface{})
|
var d interface{}
|
||||||
err := json.Unmarshal(b.Data, &d)
|
err := json.Unmarshal(b.Data, &d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tr, err
|
return tr, err
|
||||||
@@ -123,7 +123,7 @@ func (p *propagateServer) DoRoomcast(ctx context.Context, r *transport.Roomcast)
|
|||||||
|
|
||||||
switch r.DataType {
|
switch r.DataType {
|
||||||
case transport.DataType_JSON:
|
case transport.DataType_JSON:
|
||||||
d := make(map[string]interface{})
|
var d interface{}
|
||||||
err := json.Unmarshal(r.Data, &d)
|
err := json.Unmarshal(r.Data, &d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tr, err
|
return tr, err
|
||||||
|
@@ -27,7 +27,7 @@ type MMHB struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//NewMongoDBBackend returns a new instance of MMHB which satisfies the ss.MultihomeBackend interface.
|
//NewMongoDBBackend returns a new instance of MMHB which satisfies the ss.MultihomeBackend interface.
|
||||||
//A new database "SSMultihome" will be created at the specified mongoURL, and under it 3 collections "activeServers",
|
//A new database "SSMultihome" will be created at the specified mongoURL, and under it 3 collections "ss.activeServers",
|
||||||
//"ss.roomcasts", and "ss.broadcasts" will be created if they don't already exist.
|
//"ss.roomcasts", and "ss.broadcasts" will be created if they don't already exist.
|
||||||
//
|
//
|
||||||
//serverName must be unique per running ss.SocketServer instance, otherwise broadcasts, and roomcasts
|
//serverName must be unique per running ss.SocketServer instance, otherwise broadcasts, and roomcasts
|
||||||
@@ -209,7 +209,6 @@ func (mmhb *MMHB) BroadcastFromBackend(b chan<- *ss.BroadcastMsg) {
|
|||||||
var d interface{}
|
var d interface{}
|
||||||
d = bcast.Data
|
d = bcast.Data
|
||||||
if bcast.JSON {
|
if bcast.JSON {
|
||||||
d = make(map[string]interface{})
|
|
||||||
err = json.Unmarshal(bcast.Data.([]byte), &d)
|
err = json.Unmarshal(bcast.Data.([]byte), &d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err.Println(err)
|
log.Err.Println(err)
|
||||||
@@ -272,7 +271,6 @@ func (mmhb *MMHB) RoomcastFromBackend(r chan<- *ss.RoomMsg) {
|
|||||||
var d interface{}
|
var d interface{}
|
||||||
d = rcast.Data
|
d = rcast.Data
|
||||||
if rcast.JSON {
|
if rcast.JSON {
|
||||||
d = make(map[string]interface{})
|
|
||||||
err = json.Unmarshal(rcast.Data.([]byte), &d)
|
err = json.Unmarshal(rcast.Data.([]byte), &d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Err.Println(err)
|
log.Err.Println(err)
|
||||||
|
Reference in New Issue
Block a user