本文整理汇总了Golang中doppler/sinkserver/websocketserver.WebsocketServer.Stop方法的典型用法代码示例。如果您正苦于以下问题:Golang WebsocketServer.Stop方法的具体用法?Golang WebsocketServer.Stop怎么用?Golang WebsocketServer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doppler/sinkserver/websocketserver.WebsocketServer
的用法示例。
在下文中一共展示了WebsocketServer.Stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var apiEndpoint = "127.0.0.1:9091"
BeforeEach(func() {
logger := loggertesthelper.Logger()
cfcomponent.Logger = logger
wsReceivedChan = make(chan []byte)
server = websocketserver.New(apiEndpoint, sinkManager, 100*time.Millisecond, 100, "dropsonde-origin", logger)
go server.Start()
serverUrl := fmt.Sprintf("ws://%s/apps/%s/stream", apiEndpoint, appId)
websocket.DefaultDialer = &websocket.Dialer{HandshakeTimeout: 10 * time.Millisecond}
Eventually(func() error { _, _, err := websocket.DefaultDialer.Dial(serverUrl, http.Header{}); return err }, 1).ShouldNot(HaveOccurred())
})
AfterEach(func() {
server.Stop()
time.Sleep(time.Millisecond * 10)
})
Describe("failed connections", func() {
It("fails without an appId", func() {
_, connectionDropped = AddWSSink(wsReceivedChan, fmt.Sprintf("ws://%s/apps//stream", apiEndpoint))
Expect(connectionDropped).To(BeClosed())
})
It("fails with bad path", func() {
_, connectionDropped = AddWSSink(wsReceivedChan, fmt.Sprintf("ws://%s/apps/my-app/junk", apiEndpoint))
Expect(connectionDropped).To(BeClosed())
})
})
示例2:
services.Add(1)
goRoutineSpawned.Add(1)
go func() {
goRoutineSpawned.Done()
defer services.Done()
TestWebsocketServer.Start()
}()
goRoutineSpawned.Wait()
})
AfterEach(func() {
sinkManager.Stop()
TestMessageRouter.Stop()
TestWebsocketServer.Stop()
services.Wait()
})
It("dumps all messages for an app user", func() {
expectedFirstMessageString := "Some data 1"
lm := factories.NewLogMessage(events.LogMessage_OUT, expectedFirstMessageString, "myOtherApp", "APP")
env1, _ := emitter.Wrap(lm, "ORIGIN")
expectedSecondMessageString := "Some data 2"
lm = factories.NewLogMessage(events.LogMessage_OUT, expectedSecondMessageString, "myOtherApp", "APP")
env2, _ := emitter.Wrap(lm, "ORIGIN")
dataReadChannel <- env1
dataReadChannel <- env2