github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/network-application.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package protocol 4 5 /* 6 ********************************************************************************** 7 Application (OSI Layer 7: Application) 8 ********************************************************************************** 9 */ 10 11 type NetworkApplicationProtocolID uint16 12 13 // Indicate standard listen and send port number register for application layer protocols. 14 // Usually Dev must register needed stream protocol not use this method to register all available protocols! 15 // Not rule but suggest to use even port number to listen||receive||response||server and odd for send||request||client 16 // https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers 17 // https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml 18 const ( 19 NetworkApplicationSRPC NetworkApplicationProtocolID = 4 20 NetworkApplicationDNS NetworkApplicationProtocolID = 50 21 NetworkApplicationHTTP NetworkApplicationProtocolID = 80 22 ) 23 24 // NetworkApplicationMultiplexer 25 type NetworkApplicationMultiplexer interface { 26 GetNetworkApplicationHandler(protocolID NetworkApplicationProtocolID) NetworkApplicationHandler 27 SetNetworkApplicationHandler(protocolID NetworkApplicationProtocolID, nah NetworkApplicationHandler) 28 DeleteNetworkApplicationHandler(protocolID NetworkApplicationProtocolID) 29 } 30 31 // NetworkApplicationHandler 32 type NetworkApplicationHandler interface { 33 ProtocolID() NetworkApplicationProtocolID 34 HandleIncomeRequest(stream Stream) (err Error) 35 36 // HandleOutcomeRequest() 37 // Due to each application handler wants its signature, implement it as a pure function inside each package. 38 // srpc.HandleOutcomeRequest(conn Connection, service Service, payload Codec) (stream Stream, err Error) 39 // http.HandleOutcomeRequest(conn Connection, service Service, httpReq *Request) (httpRes *Response, err Error) { 40 }