forked from link1st/gowebsocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
接收消息显示界面
- Loading branch information
Showing
10 changed files
with
428 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Created by GoLand. | ||
* User: link1st | ||
* Date: 2019-08-01 | ||
* Time: 10:40 | ||
*/ | ||
|
||
package models | ||
|
||
const ( | ||
messageTypeText = "text" | ||
) | ||
|
||
// 消息的定义 | ||
type Message struct { | ||
Target string `json:"target"` // 目标 | ||
Type string `json:"type"` // 消息类型 text/img/ | ||
Msg string `json:"msg"` // 消息内容 | ||
From string `json:"from"` // 发送者 | ||
} | ||
|
||
func NewTestMsg(from string, Msg string) (message *Message) { | ||
|
||
message = &Message{ | ||
Type: messageTypeText, | ||
From: from, | ||
Msg: Msg, | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Created by GoLand. | ||
* User: link1st | ||
* Date: 2019-08-01 | ||
* Time: 10:46 | ||
*/ | ||
|
||
package models | ||
|
||
import "encoding/json" | ||
|
||
/************************ 响应数据 **************************/ | ||
type Head struct { | ||
Seq string `json:"seq"` // 消息的Id | ||
Cmd string `json:"cmd"` // 消息的cmd | ||
Response *Response `json:"response"` // 消息体 | ||
} | ||
|
||
type Response struct { | ||
Code int `json:"code"` | ||
CodeMsg string `json:"codeMsg"` | ||
Data interface{} `json:"data"` // 数据 json | ||
} | ||
|
||
// push 数据结构体 | ||
type PushMsg struct { | ||
Seq string `json:"seq"` | ||
Uuid uint64 `json:"uuid"` | ||
Type string `json:"type"` | ||
Msg string `json:"msg"` | ||
} | ||
|
||
// 设置返回消息 | ||
func NewResponseHead(seq string, cmd string, code int, codeMsg string, data interface{}) *Head { | ||
response := NewResponse(code, codeMsg, data) | ||
|
||
return &Head{Seq: seq, Cmd: cmd, Response: response} | ||
} | ||
|
||
func (h *Head) String() (headStr string) { | ||
headBytes, _ := json.Marshal(h) | ||
headStr = string(headBytes) | ||
|
||
return | ||
} | ||
|
||
func NewResponse(code int, codeMsg string, data interface{}) *Response { | ||
return &Response{Code: code, CodeMsg: codeMsg, Data: data} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.