Commit 7da3d842 authored by AlexStocks's avatar AlexStocks

add wss test

parent 630edfeb
var serverAddress = '192.168.8.3:10000';
// var serverAddress = '127.0.0.1:10000';
// var serverAddress = '192.168.8.3:10000';
var serverAddress = '127.0.0.1:10000';
......@@ -40,7 +40,7 @@ $(function() {
var $chatPage = $('.chat.page'); // The chatroom page
// var socket = new WebSocket('ws://192.168.35.1:10000/echo');
var socket = new WebSocket('ws://' + serverAddress + '/echo');
var socket = new WebSocket('wss://' + serverAddress + '/echo');
// // Setting binaryType to accept received binary as either 'blob' or 'arraybuffer'. In default it is 'blob'.
// socket.binaryType = 'arraybuffer';
// socket.binaryType = ''
......
......@@ -69,6 +69,11 @@ type (
FailFastTimeout string `default:"5s"`
failFastTimeout time.Duration
// cert
// generate_cert -host ikuernto.com
CertFile string
KeyFile string
// session tcp parameters
GettySessionParam GettySessionParam `required:"true"`
}
......
......@@ -16,6 +16,7 @@ import (
)
import (
"fmt"
"github.com/AlexStocks/getty"
log "github.com/AlexStocks/log4go"
)
......@@ -36,6 +37,7 @@ type MessageHandler struct{}
func (this *MessageHandler) Handle(session getty.Session, pkg *EchoPackage) error {
log.Debug("get echo package{%s}", pkg)
fmt.Printf("get echo package{%s}\n", pkg)
return session.WritePkg(pkg)
}
......
......@@ -149,8 +149,13 @@ func initServer() {
}
// run server
server.RunWSEventLoop(newSession, pathList[idx])
log.Debug("server bind addr{ws://%s/%s} ok!", addr, pathList[idx])
if conf.CertFile != "" && conf.KeyFile != "" {
server.RunWSSEventLoop(newSession, pathList[idx], conf.CertFile, conf.KeyFile)
log.Debug("server bind addr{wss://%s/%s} ok!", addr, pathList[idx])
} else {
server.RunWSEventLoop(newSession, pathList[idx])
log.Debug("server bind addr{ws://%s/%s} ok!", addr, pathList[idx])
}
serverList = append(serverList, server)
}
}
......
-----BEGIN CERTIFICATE-----
MIIC9TCCAd2gAwIBAgIRANmtP/9kdedbv2KRg4M/wTAwDQYJKoZIhvcNAQELBQAw
EjEQMA4GA1UEChMHQW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WVfoTvvgNUX
EV8NJGIrgs2wd1FnxzyMWAYhxezmo2rR9uMcm0DSjogK9fkCe/UBysQlIyLbtpzK
rac+cJC2cwLVVPEBkv3zUZcCgYAm+1ePF8XzMNGOyqFpGfHgnAvJIMAG6OCOx5Tp
6tJojVsZrt/zhHNLKOgTDleVwZmK3zZ5HhzfQNrujSCB0XegaThjxiEdfo8tqU3M
Q5bnoNDiaFt8y0UykU2dClHp9mCGY3Z0BxMMZhD8vtGCCTaqOYaf4JoUzc67n/k4
8d3CYQKBgGqlG9IKqDbBm35rN9yIFHRXaruFARn6ItfzvC2Ikgb9FruuiMiQf4sm
jI9/tdhEt+qVDL3+n/aH7qY1A4QePVeb2IMeUCaJFWIIl0a5hk3RCDIx1jSDL6IO
Iy5zaZECHcGZVNa983db9edzMuV4kOa60qavd+3SxjT/3fztlNHl
-----END RSA PRIVATE KEY-----
......@@ -21,6 +21,10 @@ SessionNumber = 700
# app
FailFastTimeout = "3s"
# cert
CertFile = "./conf/cert/cert.pem"
KeyFile = "./conf/cert/key.pem"
# tcp
[GettySessionParam]
CompressEncoding = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment