互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

5 years ago
  1. package ws_send_service
  2. import (
  3. "github.com/kirinlabs/HttpRequest"
  4. )
  5. var SendUrl = "https://api.ouxuanhudong.com:20182/PcClient/Connect/MessageCtl/Receive"
  6. // https://api.hudongzhuanjia.com:20182/PcClient/Connect/MessageCtl/Receive
  7. // func init() {
  8. // SendUrl = "http://127.0.0.1:20182/PcClient/Handle/MessageCtl/receive"
  9. // }
  10. type Message struct {
  11. Type string `json:"type"`
  12. Tag string `json:"tag"`
  13. Dest int64 `json:"dest"`
  14. RoomId string `json:"room_id"`
  15. Data map[string]interface{} `json:"data"`
  16. }
  17. // pc send upper wall
  18. func SendUpperWall(roomId string, tag string, dest int64, data map[string]interface{}) {
  19. m := Message{
  20. Type: "upper_wall",
  21. Tag: tag,
  22. Dest: dest,
  23. RoomId: roomId,
  24. Data: data,
  25. }
  26. HttpRequest.Debug(true).JSON().Post(SendUrl, HttpRequest.Json(&m))
  27. }
  28. func SendShakeRedEnvelope(roomId string, tag string, dest int64, data map[string]interface{}) {
  29. m := Message{
  30. Type: "shake_rb",
  31. Tag: tag,
  32. Dest: dest,
  33. RoomId: roomId,
  34. Data: data,
  35. }
  36. HttpRequest.Debug(true).JSON().Post(SendUrl, HttpRequest.Json(&m))
  37. }
  38. func SendBarrage(roomId string, tag string, dest int64, data map[string]interface{}) {
  39. m := Message{
  40. Type: "barrage",
  41. Tag: tag,
  42. Dest: dest,
  43. RoomId: roomId,
  44. Data: data,
  45. }
  46. HttpRequest.Debug(true).JSON().Post(SendUrl, HttpRequest.Json(&m))
  47. }
  48. func SendSign(roomId string, tag string, dest int64, data map[string]interface{}) {
  49. m := Message{
  50. Type: "sign_up",
  51. Tag: tag,
  52. Dest: dest,
  53. RoomId: roomId,
  54. Data: data,
  55. }
  56. HttpRequest.Debug(true).JSON().Post(SendUrl, HttpRequest.Json(&m))
  57. }
  58. func SendAuction(roomId string, tag string, dest int64, data map[string]interface{}) {
  59. m := Message{
  60. Type: "auction",
  61. Tag: tag,
  62. RoomId: roomId,
  63. Dest: dest,
  64. Data: data,
  65. }
  66. HttpRequest.Debug(true).JSON().Post(SendUrl, HttpRequest.Json(&m))
  67. }
  68. // 可以设置通用的ws链接进行通信