From 9f917b497416d6acd59dbd291e32fcabf5f80802 Mon Sep 17 00:00:00 2001 From: Raz Varren Date: Tue, 6 Sep 2016 01:50:27 +0000 Subject: [PATCH] map[string]interface{} does not cover all possible json data types --- backend/ssgrpc/server.go | 4 ++-- backend/ssmongo/ssmongo.go | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/ssgrpc/server.go b/backend/ssgrpc/server.go index d620ab2..b524a83 100644 --- a/backend/ssgrpc/server.go +++ b/backend/ssgrpc/server.go @@ -80,7 +80,7 @@ func (p *propagateServer) DoBroadcast(ctx context.Context, b *transport.Broadcas switch b.DataType { case transport.DataType_JSON: - d := make(map[string]interface{}) + var d interface{} err := json.Unmarshal(b.Data, &d) if err != nil { return tr, err @@ -123,7 +123,7 @@ func (p *propagateServer) DoRoomcast(ctx context.Context, r *transport.Roomcast) switch r.DataType { case transport.DataType_JSON: - d := make(map[string]interface{}) + var d interface{} err := json.Unmarshal(r.Data, &d) if err != nil { return tr, err diff --git a/backend/ssmongo/ssmongo.go b/backend/ssmongo/ssmongo.go index 67f19ff..cb4f5e7 100644 --- a/backend/ssmongo/ssmongo.go +++ b/backend/ssmongo/ssmongo.go @@ -27,7 +27,7 @@ type MMHB struct { } //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. // //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{} d = bcast.Data if bcast.JSON { - d = make(map[string]interface{}) err = json.Unmarshal(bcast.Data.([]byte), &d) if err != nil { log.Err.Println(err) @@ -272,7 +271,6 @@ func (mmhb *MMHB) RoomcastFromBackend(r chan<- *ss.RoomMsg) { var d interface{} d = rcast.Data if rcast.JSON { - d = make(map[string]interface{}) err = json.Unmarshal(rcast.Data.([]byte), &d) if err != nil { log.Err.Println(err)