This commit is contained in:
crusader 2017-07-26 19:00:39 +09:00
parent 0d428d20c0
commit e759caacb7
5 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"server": { "server": {
"ip": "localhost", "ip": "127.0.0.1",
"port": 18081, "port": 18081,
"tls": false "tls": false
}, },

BIN
debug

Binary file not shown.

View File

@ -49,7 +49,7 @@ func main() {
}) })
}) })
http.Handle("/ws", ws.HTTPHandler()) http.Handle("/rpc", ws.HTTPHandler())
log.Printf("Address: %s, UseTLS: %t", addr, useTLS) log.Printf("Address: %s, UseTLS: %t", addr, useTLS)
http.ListenAndServe(addr, nil) http.ListenAndServe(addr, nil)

View File

@ -57,7 +57,7 @@ type handler struct {
// NewRequest returns a CodecRequest. // NewRequest returns a CodecRequest.
func (h *handler) Handle(data []byte) ([]byte, *protocol.Error) { func (h *handler) Handle(data []byte) ([]byte, *protocol.Error) {
req := new(Request) req := Request{}
err := json.Unmarshal(data, &req) err := json.Unmarshal(data, &req)
if nil != err { if nil != err {
return nil, protocol.NewError(protocol.E_PARSE, err, nil) return nil, protocol.NewError(protocol.E_PARSE, err, nil)

View File

@ -165,8 +165,11 @@ func (c *client) onMessageReceived(messageType int, r io.Reader) {
req := new(Request) req := new(Request)
err := json.NewDecoder(r).Decode(req) err := json.NewDecoder(r).Decode(req)
if err != nil { if err != nil {
log.Println(err)
} }
log.Println(req.Body)
h := c.server.ProtocolHandler(req.Protocol) h := c.server.ProtocolHandler(req.Protocol)
if nil == h { if nil == h {