map[string]interface{} does not cover all possible json data types

This commit is contained in:
Raz Varren
2016-09-06 01:50:27 +00:00
parent 00af69debe
commit 9f917b4974
2 changed files with 3 additions and 5 deletions

View File

@@ -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

View File

@@ -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)