Use WriteMessage to simplify

This commit is contained in:
Iwasaki Yudai 2015-08-28 17:49:25 +09:00
parent c71cc21721
commit 02e0b6fafd

View File

@ -127,23 +127,17 @@ func (context *clientContext) sendInitialize() error {
writer.Close() writer.Close()
prefs, _ := json.Marshal(context.app.preferences) prefs, _ := json.Marshal(context.app.preferences)
writer, err = context.connection.NextWriter(websocket.TextMessage) context.connection.WriteMessage(
if err != nil { websocket.TextMessage,
return err append([]byte{SetPreferences}, prefs...),
} )
writer.Write([]byte{SetPreferences})
writer.Write(prefs)
writer.Close()
if context.app.options.EnableReconnect { if context.app.options.EnableReconnect {
reconnect, _ := json.Marshal(context.app.options.ReconnectTime) reconnect, _ := json.Marshal(context.app.options.ReconnectTime)
writer, err = context.connection.NextWriter(websocket.TextMessage) context.connection.WriteMessage(
if err != nil { websocket.TextMessage,
return err append([]byte{SetReconnect}, reconnect...),
} )
writer.Write([]byte{SetReconnect})
writer.Write(reconnect)
writer.Close()
} }
return nil return nil