Пример #1
0
        public ApiDescription?FindApiDescription(string requestPath)
        {
            var path = ProtocolConstants.NormalizeRelativePath(requestPath);

            var groups = _apiDescriptionProvider.ApiDescriptionGroups.Items;

            for (var i = 0; i < groups.Count; i++)
            {
                var group = groups[i];
                for (var j = 0; j < group.Items.Count; j++)
                {
                    var item = group.Items[j];
                    if (string.Equals(item.RelativePath, path, StringComparison.OrdinalIgnoreCase))
                    {
                        return(item.ActionDescriptor is GrpcActionDescriptor ? item : null);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        public void Accept(ref int requestID)
        {
            if (m_enmState != SockState.sckClosed) {
                Err().Raise(modSocketMaster.sckInvalidOp, "CSocketMaster.Accept", "Invalid operation at current state");
            }

            int lngResult = 0;
            sockaddr_in udtSockAddr = default(sockaddr_in);
            int lngErrorCode = 0;

            m_lngSocketHandle = requestID;
            m_enmProtocol = ProtocolConstants.sckTCPProtocol;
            ProcessOptions();

            if (!modSocketMaster.IsAcceptRegistered(requestID)) {
                if (modSocketMaster.IsSocketRegistered(requestID)) {
                    Err().Raise(modSocketMaster.sckBadState, "CSocketMaster.Accept", "Wrong protocol or connection state for the requested transaction or request");
                } else {
                    m_blnAcceptClass = true;
                    m_enmState = SockState.sckConnected;
                    Debug.Print("STATE: sckConnected");
                    //UPGRADE_ISSUE: ObjPtr function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
                    modSocketMaster.RegisterSocket(m_lngSocketHandle, VarPtr.VarPtr(this), false);
                    return;
                }
            }

            CSocketMaster clsSocket = null;
            clsSocket = modSocketMaster.GetAcceptClass(requestID);
            modSocketMaster.UnregisterAccept(requestID);

            lngResult = api_getsockname(m_lngSocketHandle, ref udtSockAddr, ref modLenB.LenB(udtSockAddr));

            if (lngResult == modSocketMaster.SOCKET_ERROR) {
                lngErrorCode = Err().LastDllError;
                Err().Raise(lngErrorCode, "CSocketMaster.Accept", modSocketMaster.GetErrorDescription(lngErrorCode));

            } else {
                m_lngLocalPortBind = modSocketMaster.IntegerToUnsigned(ref api_ntohs(udtSockAddr.sin_port));
                m_strLocalIP = modSocketMaster.StringFromPointer(api_inet_ntoa(udtSockAddr.sin_addr));

            }

            GetRemoteInfo(m_lngSocketHandle, ref m_lngRemotePort, ref m_strRemoteHostIP, ref m_strRemoteHost);
            m_enmState = SockState.sckConnected;
            Debug.Print("STATE: sckConnected");

            if (clsSocket.BytesReceived > 0) {
                clsSocket.GetData(m_strRecvBuffer);
            }

            //UPGRADE_ISSUE: ObjPtr function is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="367764E5-F3F8-4E43-AC3E-7FE0B5E074E2"'
            modSocketMaster.Subclass_ChangeOwner(requestID, VarPtr.VarPtr(this));

            if (Strings.Len(m_strRecvBuffer) > 0)
                if (DataArrival != null) {
                    DataArrival(Strings.Len(m_strRecvBuffer));
                }

            if (clsSocket.State == SockState.sckClosing) {
                m_enmState = SockState.sckClosing;
                Debug.Print("STATE: sckClosing");
                if (CloseSck != null) {
                    CloseSck();
                }
            }

            clsSocket = null;
        }