本文整理汇总了C#中ZyGames.Framework.RPC.IO.MessageStructure类的典型用法代码示例。如果您正苦于以下问题:C# MessageStructure类的具体用法?C# MessageStructure怎么用?C# MessageStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageStructure类属于ZyGames.Framework.RPC.IO命名空间,在下文中一共展示了MessageStructure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SuccessCallback
protected override void SuccessCallback(MessageStructure writer, MessageHead head)
{
int type = writer.ReadInt();
if (type == 1)
{
int recordCount = writer.ReadInt();
JsonObject jsonContainer = new JsonObject();
List<JsonObject> jsonList = new List<JsonObject>();
for (int i = 0; i < recordCount; i++)
{
writer.RecordStart();
var item = new JsonObject();
item.Add("NoticeID", writer.ReadString());
item.Add("Title", writer.ReadString());
item.Add("Content", writer.ReadString());
item.Add("IsBroadcast", writer.ReadInt());
item.Add("IsTop", writer.ReadInt());
item.Add("Creater", writer.ReadString());
item.Add("CreateDate", writer.ReadString());
item.Add("ExpiryDate", writer.ReadString());
jsonList.Add(item);
writer.RecordEnd();
}
jsonContainer.Add("total", recordCount);
jsonContainer.Add("rows", jsonList.ToArray());
WriteTableJson(jsonContainer);
}
}
示例2: OnReceiveTimeout
public override void OnReceiveTimeout(string clientAddress, byte[] receiveData)
{
try
{
BufferReader reader = new BufferReader(receiveData);
string paramString = reader.ReadPacketString();
paramString = HttpUtility.UrlDecode(paramString, Encoding.UTF8);
int index = paramString.IndexOf("?d=");
if (index != -1)
{
index += 3;
paramString = paramString.Substring(index, paramString.Length - index);
}
PacketMessage receivePacket = ParsePacketMessage(clientAddress, paramString, ConnectType.Tcp);
var recHead = receivePacket.Head;
int errorCode = LanguageHelper.GetLang().ErrorCode;
string errorMsg = LanguageHelper.GetLang().RequestTimeout;
MessageHead head = new MessageHead(recHead.MsgId, recHead.ActionId, "st", errorCode, errorMsg);
head.HasGzip = true;
MessageStructure ds = new MessageStructure();
ds.WriteBuffer(head);
byte[] data = ds.ReadBuffer();
OnSendCompleted(clientAddress, data);
}
catch (Exception ex)
{
TraceLog.WriteError("Send to client {0} timeout error:{1}", clientAddress, ex);
}
}
示例3: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
responsePack = ProtoBufUtils.Deserialize<Response1010Pack>(netReader.Buffer);
string responseDataInfo = "";
responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1010Pack>(req) + "\n";
responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1010Pack>(responsePack) + "\n";
DecodePacketInfo = responseDataInfo;
int childStepId = getChild(1010);
System.Console.WriteLine("childStepID:" + childStepId);
if (childStepId > 0)
{
System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
/*
req.UserID = GetParamsData("UserID", req.UserID);
req.identify = GetParamsData("identify", req.identify);
req.version = GetParamsData("version", req.version);
req.the3rdUserID = GetParamsData("the3rdUserID", req.the3rdUserID);
req.happyPoint = GetParamsData("happyPoint", req.happyPoint);
req.Rate = GetParamsData("Rate", req.Rate);
req.index = GetParamsData("index", req.index);
req.strThe3rdUserID = GetParamsData("strThe3rdUserID", req.strThe3rdUserID);
req.typeUser = GetParamsData("typeUser", req.typeUser);
*/
dic.Add("UserID", req.UserID.ToString());
dic.Add("index", responsePack.index.ToString());
dic.Add("the3rdUserID", req.the3rdUserID.ToString());
dic.Add("strThe3rdUserID", req.strThe3rdUserID);
SetChildStep(childStepId.ToString(), _setting,dic);
}
return true;
}
示例4: ResponseError
public virtual void ResponseError(BaseGameResponse response, ActionGetter actionGetter, int errorCode, string errorInfo)
{
MessageHead head = new MessageHead(actionGetter.GetMsgId(), actionGetter.GetActionId(), errorCode, errorInfo);
MessageStructure sb = new MessageStructure();
sb.WriteBuffer(head);
response.BinaryWrite(sb.PopBuffer());
}
示例5: ProcessRequest
/// <summary>
///
/// </summary>
/// <param name="package"></param>
/// <param name="param"></param>
/// <returns></returns>
public byte[] ProcessRequest(object package, object param)
{
var httpresponse = new SocketGameResponse();
ActionGetter actionGetter = null;
try
{
httpresponse.WriteErrorCallback += new ScutActionDispatcher().ResponseError;
RequestPackage p = package as RequestPackage;
actionGetter = param as ActionGetter;
if (!string.IsNullOrEmpty(p.RouteName))
{
if (CheckRemote(p.RouteName, actionGetter))
{
MessageStructure response = new MessageStructure();
OnCallRemote(p.RouteName, actionGetter, response);
return response.PopBuffer();
}
httpresponse.WriteError(actionGetter, 10000, "No permission");
}
else
{
DoAction(actionGetter, httpresponse);
}
return httpresponse.ReadByte();
}
catch (Exception ex)
{
TraceLog.WriteError("Request error:{0}", ex);
MessageStructure response = new MessageStructure();
response.WriteBuffer(new MessageHead(0, 10000, "request error"));
return response.PopBuffer();
}
}
示例6: HttpServiceRequest
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public HttpServiceRequest(HttpContext context)
{
_buffer = new MessageStructure();
httpGet = new HttpGet(context.Request);
response = new HttpGameResponse(context.Response);
ParamString = httpGet.ParamString;
SessionId = httpGet.SessionId;
}
示例7: CtorErrMsg
public static byte[] CtorErrMsg(int error, string msg, NameValueCollection requestParam)
{
int msgId = Convert.ToInt32(requestParam["msgid"]);
int actionid = Convert.ToInt32(requestParam["actionid"]);
var ms = new MessageStructure();
var head = new MessageHead(msgId, actionid, "st", error, msg);
ms.WriteBuffer(head);
return ms.PosGzipBuffer();
}
示例8: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
responsePack = ProtoBufUtils.Deserialize<Response1003Pack>(netReader.Buffer);
string responseDataInfo = "";
responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1003Pack>(req) + "\n";
responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1003Pack>(responsePack) + "\n";
DecodePacketInfo = responseDataInfo;
return true;
}
示例9: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
_session.Context.SessionId = reader.ReadString();
_session.Context.UserId = reader.ReadString().ToInt();
int UserType = reader.ReadInt();
string LoginTime = reader.ReadString();
int GuideID = reader.ReadInt();
if (GuideID == 1005)
{
SetChildStep("1005");
}
return true;
}
示例10: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
responsePack = ProtoBufUtils.Deserialize<ResponsePack>(netReader.Buffer);
string responseDataInfo = "";
responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1000Pack>(req) + "\n";
responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<ResponsePack>(responsePack) + "\n";
DecodePacketInfo = responseDataInfo;
int childStepId = getChild(1000);
if(childStepId>0)
{
System.Collections.Generic.Dictionary<string,string> dic = new System.Collections.Generic.Dictionary<string,string>();
dic.Add("UserID",responsePack.UserID.ToString()) ;
SetChildStep(childStepId.ToString(),_setting,dic);
}
return true;
}
示例11: BuildLuaFile
public static string BuildLuaFile(List<ParamInfoModel> paramList, MessageStructure msgReader, string[] keyNames)
{
var respParams = paramList.Where(p => p.ParamType == 2).OrderBy(p => p.SortID);
StringBuilder containerBuilder = new StringBuilder();
int loopDepth = 0;//循环深度
List<ParamInfoModel> recordQueue = new List<ParamInfoModel>();
foreach (var record in respParams)
{
string fieldName = record.Field;
FieldType fieldType = record.FieldType;
string fieldValue = "";
if (loopDepth > 0 && fieldType == FieldType.End)
{
loopDepth--;
recordQueue.Add(record);
}
if (loopDepth == 0 && recordQueue.Count > 0)
{
//处理循环记录
ParseRecordEnd(containerBuilder, msgReader, recordQueue, loopDepth, 0, keyNames);
recordQueue.Clear();
}
if (loopDepth == 0)
{
if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
{
//自动登录
}
if (fieldType == FieldType.Record)
{
loopDepth++;
recordQueue.Add(record);
}
}
else if (fieldType != FieldType.End)
{
if (fieldType == FieldType.Record)
{
loopDepth++;
}
recordQueue.Add(record);
}
}
return containerBuilder.ToString();
}
示例12: BuildLuaFile
public static string BuildLuaFile(DataTable table, MessageStructure msgReader, string[] keyNames)
{
StringBuilder containerBuilder = new StringBuilder();
int loopDepth = 0;//ѭ�����
List<DataRow> recordQueue = new List<DataRow>();
foreach (DataRow record in table.Rows)
{
string fieldName = record["Field"].ToString();
FieldType fieldType = (FieldType)Enum.Parse(typeof(FieldType), record["FieldType"].ToString());
string fieldValue = "";
if (loopDepth > 0 && fieldType == FieldType.End)
{
loopDepth--;
recordQueue.Add(record);
}
if (loopDepth == 0 && recordQueue.Count > 0)
{
//����ѭ����¼
ParseRecordEnd(containerBuilder, msgReader, recordQueue, loopDepth, 0, keyNames);
recordQueue.Clear();
}
if (loopDepth == 0)
{
if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
{
//�Զ���¼
}
if (fieldType == FieldType.Record)
{
loopDepth++;
recordQueue.Add(record);
}
}
else if (fieldType != FieldType.End)
{
if (fieldType == FieldType.Record)
{
loopDepth++;
}
recordQueue.Add(record);
}
}
return containerBuilder.ToString();
}
示例13: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
try
{
responsePack = ProtoBufUtils.Deserialize<Action3000Response>(netReader.Buffer);
string responseDataInfo = "";
responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Action3000Request>(req) + "\n";
responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Action3000Response>(responsePack) + "\n";
DecodePacketInfo = responseDataInfo;
}
catch (System.Exception e)
{
System.Console.WriteLine(e.Message);
}
return true;
}
示例14: RequestTimeout
public void RequestTimeout(HttpConnection connection)
{
var param = connection.Param;
int msgId = param.Get("MsgId").ToInt();
int actionId = param.Get("ActionId").ToInt();
int errorCode = LanguageHelper.GetLang().ErrorCode;
string errorMsg = LanguageHelper.GetLang().RequestTimeout;
var head = new MessageHead(msgId, actionId, "st", errorCode, errorMsg);
head.HasGzip = true;
var ms = new MessageStructure();
ms.WriteBuffer(head);
byte[] data = ms.ReadBuffer();
string remoteAddress = connection.Context.Request.RemoteEndPoint.Address.ToString();
string successMsg = string.Format("{0}>>发送超时到{1} {2}字节!",
DateTime.Now.ToString("HH:mm:ss:ms"), remoteAddress, data.Length);
Console.WriteLine(successMsg);
OnResponseCompleted(connection, data);
}
示例15: DecodePacket
protected override bool DecodePacket(MessageStructure reader, MessageHead head)
{
responsePack = ProtoBufUtils.Deserialize<ResponsePack>(netReader.Buffer);
string responseDataInfo = "";
responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request2000Pack>(req) + "\n";
responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<ResponsePack>(responsePack) + "\n";
DecodePacketInfo = responseDataInfo;
int childStepId = getChild(2000);
System.Console.WriteLine("childStepID:"+childStepId);
if (childStepId > 0)
{
System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
/*
req.token = GetParamsData("token",req.token);
req.typeUser = GetParamsData("typeUser",req.typeUser);
req.version = GetParamsData("version", req.version);
req.UserID = GetParamsData("UserID", req.UserID);
*/
SetChildStep(childStepId.ToString(),_setting,dic);
}
return true;
}