Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-userProxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-userProxy
Commits
cfaf256a
Commit
cfaf256a
authored
Aug 18, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:去掉日志
parent
d4e1afb6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
main.go
main.go
+17
-18
No files found.
main.go
View file @
cfaf256a
...
...
@@ -2,7 +2,6 @@ package main
import
(
"context"
"encoding/json"
"flag"
"fmt"
"hilo-userProxy/common"
...
...
@@ -179,18 +178,18 @@ func serverWebsocket(w http.ResponseWriter, r *http.Request) {
ci
.
IsLogin
=
true
ci
.
HeartbeatTime
=
now
logger
.
Infof
(
"Bind to channel %v"
,
writeChan
)
//
logger.Infof("Bind to channel %v", writeChan)
setUserChan
(
ci
.
Uid
,
ci
.
RemoteAddr
,
writeChan
)
}
}
}
}
else
if
msgType
==
common
.
MsgTypeHeartBeat
{
status
,
extUid
,
err
:=
processHeartBeat
(
pbData
)
logger
.
Infof
(
"heartbeat"
)
//
logger.Infof("heartbeat")
if
err
==
nil
{
ci
.
HeartbeatTime
=
time
.
Now
()
if
len
(
ci
.
ExternalId
)
==
0
{
logger
.
Infof
(
"Received first heartbeat"
)
//
logger.Infof("Received first heartbeat")
ci
.
ExternalId
=
extUid
...
...
@@ -221,7 +220,7 @@ func serverWebsocket(w http.ResponseWriter, r *http.Request) {
rsp
:=
&
userProxy
.
GlobalGiftBannerRsp
{}
err
:=
proto
.
Unmarshal
(
pbData
,
rsp
)
if
err
==
nil
{
logger
.
Infof
(
"GlobalGiftBannerRsp, msgType = %d, %v"
,
msgType
,
rsp
)
//
logger.Infof("GlobalGiftBannerRsp, msgType = %d, %v", msgType, rsp)
}
else
{
logger
.
Errorf
(
"Unmarshal error"
)
}
...
...
@@ -232,7 +231,7 @@ func serverWebsocket(w http.ResponseWriter, r *http.Request) {
})
rsp
,
err
:=
processBizRequest
(
logger
,
ci
.
Uid
,
pbData
)
if
err
==
nil
&&
rsp
!=
nil
{
logger
.
Infof
(
"processBizRequest rsp %+v"
,
rsp
)
//
logger.Infof("processBizRequest rsp %+v", rsp)
if
buffer
,
err
:=
proto
.
Marshal
(
rsp
);
err
==
nil
{
writeChan
<-
ProtoData
{
...
...
@@ -267,15 +266,15 @@ func serverWebsocket(w http.ResponseWriter, r *http.Request) {
}
}
logger
.
Infof
(
"exiting read loop for token %s, user %d"
,
ci
.
Token
,
ci
.
Uid
)
sz
:=
removeUserChan
(
ci
.
Uid
,
ci
.
RemoteAddr
)
removeUserChan
(
ci
.
Uid
,
ci
.
RemoteAddr
)
b
,
_
:=
json
.
Marshal
(
ci
)
logger
.
Infof
(
"exiting read loop for %s, size = %d"
,
string
(
b
),
sz
)
//
b, _ := json.Marshal(ci)
//
logger.Infof("exiting read loop for %s, size = %d", string(b), sz)
if
ci
.
IsLogin
{
err
,
status
:=
doLogout
(
ci
.
RemoteAddr
,
ci
.
Uid
)
err
,
_
:=
doLogout
(
ci
.
RemoteAddr
,
ci
.
Uid
)
if
err
==
nil
{
logger
.
Printf
(
"logout result %d"
,
status
)
//
logger.Printf("logout result %d", status)
}
else
{
logger
.
Printf
(
"Logout failed, %s"
,
err
.
Error
())
}
...
...
@@ -341,7 +340,7 @@ Loop:
}
atomic
.
AddUint64
(
&
serialNum
,
1
)
logger
.
Infof
(
"About to send msgType = %d, size = %d"
,
d
.
MsgType
,
len
(
d
.
Data
))
//
logger.Infof("About to send msgType = %d, size = %d", d.MsgType, len(d.Data))
data
:=
common
.
EncodeMessage
(
d
.
MsgType
,
serialNum
,
d
.
Data
)
err
=
ws
.
WriteMessage
(
websocket
.
BinaryMessage
,
data
)
if
err
!=
nil
{
...
...
@@ -349,8 +348,8 @@ Loop:
}
}
}
b
,
_
:=
json
.
Marshal
(
ci
)
logger
.
Infof
(
"exiting write loop:%s"
,
string
(
b
))
//
b, _ := json.Marshal(ci)
//
logger.Infof("exiting write loop:%s", string(b))
}
func
processLogin
(
logger
*
log
.
Entry
,
clientAddr
string
,
pbData
[]
byte
)
(
string
,
uint64
,
*
userProxy
.
LoginRsp
,
error
)
{
...
...
@@ -423,7 +422,7 @@ func processEnterRoom(logger *log.Entry, uid uint64, pbData []byte) error {
if
err
==
nil
{
err
,
status
:=
doEnterRoom
(
uid
,
msg
.
GroupId
)
if
err
==
nil
&&
status
==
common
.
Login_success
{
logger
.
Infof
(
"enter room success,uid:%v,group:%v"
,
uid
,
msg
.
GroupId
)
//
logger.Infof("enter room success,uid:%v,group:%v", uid, msg.GroupId)
}
else
{
logger
.
Warnf
(
"login RPC failed for %d, %v"
,
status
,
err
)
}
...
...
@@ -439,7 +438,7 @@ func processLeaveRoom(logger *log.Entry, uid uint64, pbData []byte) error {
if
err
==
nil
{
err
,
status
:=
doLeaveRoom
(
uid
,
msg
.
GroupId
)
if
err
==
nil
&&
status
==
common
.
Login_success
{
logger
.
Infof
(
"leave room success,uid:%v,group:%v"
,
uid
,
msg
.
GroupId
)
//
logger.Infof("leave room success,uid:%v,group:%v", uid, msg.GroupId)
}
else
{
logger
.
Warnf
(
"login RPC failed for %d, %v"
,
status
,
err
)
}
...
...
@@ -455,7 +454,7 @@ func processRoomHeartbeat(logger *log.Entry, uid uint64, pbData []byte) error {
if
err
==
nil
{
err
,
status
:=
doRoomHeartbeat
(
uid
,
msg
.
GroupId
)
if
err
==
nil
&&
status
==
common
.
Login_success
{
logger
.
Infof
(
"room heartbeat success,uid:%v,group:%v"
,
uid
,
msg
.
GroupId
)
//
logger.Infof("room heartbeat success,uid:%v,group:%v", uid, msg.GroupId)
}
else
{
logger
.
Warnf
(
"login RPC failed for %d, %v"
,
status
,
err
)
}
...
...
@@ -469,7 +468,7 @@ func processGroupMicChangeRsp(logger *log.Entry, uid uint64, pbData []byte) erro
msg
:=
&
userProxy
.
GroupMicChangeRsp
{}
err
:=
proto
.
Unmarshal
(
pbData
,
msg
)
if
err
==
nil
{
logger
.
Infof
(
"groupMicChangeRsp,uid:%v,seqId:%v"
,
uid
,
msg
.
SeqId
)
//
logger.Infof("groupMicChangeRsp,uid:%v,seqId:%v", uid, msg.SeqId)
}
else
{
return
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment