当前位置: 首页>>代码示例>>C#>>正文


C# GameAction.Send方法代码示例

本文整理汇总了C#中GameAction.Send方法的典型用法代码示例。如果您正苦于以下问题:C# GameAction.Send方法的具体用法?C# GameAction.Send怎么用?C# GameAction.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameAction的用法示例。


在下文中一共展示了GameAction.Send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HttpGetRequest

    private IEnumerator HttpGetRequest(GameAction gameAction, object userData, IHeadFormater formater, bool showLoading)
    {
        string url = NetWriter.GetUrl();
        byte[] postData = gameAction.Send(userData);
        DateTime start = DateTime.Now;
        HttpPackage httpPackage = new HttpPackage();
        httpPackage.WwwObject = new WWW(url, postData);
        httpPackage.ActionId = gameAction.ActionId;
        httpPackage.Action = gameAction;
        httpPackage.Reader = new NetReader(formater);
        httpPackage.UserData = userData;

        if (RequestNotify != null && showLoading)
        {
            RequestNotify(Net.Status.eStartRequest);
        }

        yield return httpPackage.WwwObject;

        if (RequestNotify != null && showLoading)
        {
            RequestNotify(Net.Status.eEndRequest);
        }
        TimeSpan tsStart = new TimeSpan(start.Ticks);
        TimeSpan tsEnd = new TimeSpan(DateTime.Now.Ticks);
        TimeSpan ts = tsEnd.Subtract(tsStart).Duration();

        if (ts.Seconds > OVER_TIME)
        {
            httpPackage.IsOverTime = true;
        }
        OnHttpRespond(httpPackage, userData);
    }
开发者ID:jinfei426,项目名称:Scut,代码行数:33,代码来源:Net.cs

示例2: SocketRequest

    /// <summary>
    /// parse input data
    /// </summary>
    /// <param name="gameAction"></param>
    /// <param name="userData"></param>
    /// <param name="formater"></param>
    /// <param name="bShowLoading"></param>
    private void SocketRequest(GameAction gameAction, object userData, IHeadFormater formater, bool bShowLoading)
    {
        if (mSocket == null)
        {
            string strUrl = NetWriter.GetUrl();
            string[] arr = strUrl.Split(new char[] { ':' });
            int nPort = int.Parse(arr[1]);
            mSocket = new SocketConnect(arr[0], nPort, formater);
        }
        gameAction.Head.MsgId = NetWriter.MsgId - 1;

        SocketPackage package = new SocketPackage();
        package.UserData = userData;
        package.MsgId = gameAction.Head.MsgId;
        package.ActionId = gameAction.ActionId;
        package.Action = gameAction;
        package.HasLoading = bShowLoading;
        package.SendTime = DateTime.Now;
        byte[] data = gameAction.Send(userData);
        NetWriter.resetData();
        if (bShowLoading)
        {
            RequestDelegate(Status.eStartRequest);
        }
        mSocket.Send(data, package);
    }
开发者ID:jinfei426,项目名称:Scut,代码行数:33,代码来源:Net.cs

示例3: SocketRequest

    /// <summary>
    /// parse input data
    /// </summary>
    /// <param name="gameAction"></param>
    /// <param name="actionParam"></param>
    /// <param name="formater"></param>
    /// <param name="bShowLoading"></param>
    private void SocketRequest(GameAction gameAction, ActionParam actionParam, IHeadFormater formater, bool bShowLoading)
    {
        if (mSocket == null)
        {
            string url = NetWriter.GetUrl();
            string[] arr = url.Split(new char[] { ':' });
            if (arr.Length != 2)
            {
                Debug.LogError("Url is error:" + url);
                return;
            }
            int nPort = int.Parse(arr[1]);
            mSocket = new SocketConnect(arr[0], nPort, formater);

        }
        gameAction.Head.MsgId = NetWriter.MsgId - 1;

        SocketPackage package = new SocketPackage();
        package.MsgId = gameAction.Head.MsgId;
        package.ActionId = gameAction.ActionId;
        package.Action = gameAction;
        package.HasLoading = bShowLoading;
        package.SendTime = DateTime.Now;
        byte[] data = gameAction.Send(actionParam);
        NetWriter.resetData();
        if (bShowLoading)
        {
            RequestDelegate(Status.eStartRequest);
        }
        mSocket.Send(data, package);
    }
开发者ID:daneric,项目名称:Scut-samples,代码行数:38,代码来源:Net.cs


注:本文中的GameAction.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。