2019-01-01 10:21
浏览 220


I want to send data from Android to Golang with . I do that with Nodejs correctly But now , i want do with Go. I cant find simple can i do that?

图片转代码服务由CSDN问答提供 功能建议

我想使用socket.io将数据从Android发送到Golang。 我使用Node.js正确地做到了,但是现在, 我想使用Go。 我找不到简单的示例。我该怎么办?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanruinong0619 2019-01-02 04:53

    I assume you would like to use a Go implementation of a Socket.IO server library instead of the standard Node.js one. If so, you can try googollee/ project. Here is an example from the project page:

    package main
    import (
    func main() {
        server, err := socketio.NewServer(nil)
        if err != nil {
        server.On("connection", func(so socketio.Socket) {
            log.Println("on connection")
            so.On("chat message", func(msg string) {
                log.Println("emit:", so.Emit("chat message", msg))
                server.BroadcastTo("chat", "chat message", msg)
            so.On("disconnection", func() {
                log.Println("on disconnect")
        server.On("error", func(so socketio.Socket, err error) {
            log.Println("error:", err)
        http.Handle("/", server)
        http.Handle("/", http.FileServer(http.Dir("./asset")))
        log.Println("Serving at localhost:5000...")
        log.Fatal(http.ListenAndServe(":5000", nil))
    解决 无用
    打赏 举报

相关推荐 更多相似问题