MCPcopy Create free account
hub / github.com/Cyinx/einx / connect

Method connect

network/tcp_client.go:61–87  ·  view source on GitHub ↗
(addr string, user_type int16)

Source from the content-addressed store, hash-verified

59}
60
61func (this *TcpClientMgr) connect(addr string, user_type int16) {
62 raw_conn, err := net.Dial("tcp", addr)
63 if err != nil {
64 slog.LogWarning("tcp_client", "tcp connect failed %v", err)
65 e := &event.ComponentEventMsg{}
66 e.MsgType = event.EVENT_COMPONENT_ERROR
67 e.Sender = this
68 e.Attach = user_type
69 e.Err = err
70 this.module.PushEventMsg(e)
71 return
72 }
73
74 m := this.module
75 h := this.agent_handler
76
77 tcp_agent := newTcpConn(raw_conn, h, Linker_TCP_OutGoing, &this.option)
78 tcp_agent.SetUserType(user_type)
79 m.PostEvent(event.EVENT_TCP_CONNECTED, tcp_agent, this.component_id)
80
81 go func() {
82 ping_mgr.AddPing(tcp_agent)
83 tcp_agent.Run()
84 ping_mgr.RemovePing(tcp_agent)
85 m.PostEvent(event.EVENT_TCP_CLOSED, tcp_agent, this.component_id)
86 }()
87}

Callers 1

ConnectMethod · 0.95

Calls 7

newTcpConnFunction · 0.85
AddPingMethod · 0.80
RemovePingMethod · 0.80
PushEventMsgMethod · 0.65
SetUserTypeMethod · 0.65
PostEventMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected