You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
4.8 KiB
135 lines
4.8 KiB
1 month ago
|
using System;
|
||
|
using System.Threading;
|
||
|
using System.Collections.Concurrent;
|
||
|
|
||
|
using Sog.Service;
|
||
|
using Sog;
|
||
|
using ProtoCSStruct;
|
||
|
using System.Text.RegularExpressions;
|
||
|
using System.Collections.Generic;
|
||
|
using Org.BouncyCastle.Bcpg;
|
||
|
using Org.BouncyCastle.Ocsp;
|
||
|
|
||
|
namespace Operation
|
||
|
{
|
||
|
public class ExchangeCodeSvc : BaseReloadableService
|
||
|
{
|
||
|
public override int GetServiceType()
|
||
|
{
|
||
|
return OperationServiceType.ExchangeCodeSvc;
|
||
|
}
|
||
|
|
||
|
public override void Dispose()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public ExchangeCodeSvc()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public void OnExchangeSaveDbRes(uint serverID, StructPacket packet)
|
||
|
{
|
||
|
ref SSExchangeCodeSaveDbRes res = ref packet.GetMessage<SSExchangeCodeSaveDbRes>();
|
||
|
|
||
|
HttpRequestInfo m_request = null;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
var id = res.Seq;
|
||
|
TraceLog.Debug("ExchangeCodeSvc.OnExchangeSaveDbRes uid {0} ", id);
|
||
|
m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == id);
|
||
|
LitJson.JsonData builder = new LitJson.JsonData();
|
||
|
HttpQueryParams queryParams = new HttpQueryParams(m_request.Http.httpRequest.Url);
|
||
|
|
||
|
Exchange.OnSaveDbMsg(id, builder, m_request.Http.httpResponse, m_request.Http.httpRequest, queryParams, ref res);
|
||
|
m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
TraceLog.Error("ExchangeCodeSvc.OnExchangeSaveDbRes Error Msg {0}", ex.Message);
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
if (m_request != null)
|
||
|
{
|
||
|
m_request.ProcessEnd = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void OnExchangeChangeStatusDbRes(uint serverID, StructPacket packet)
|
||
|
{
|
||
|
ref SSExchangeStatusChangeRes res = ref packet.GetMessage<SSExchangeStatusChangeRes>();
|
||
|
|
||
|
HttpRequestInfo m_request = null;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
var id = (uint)res.ReqId;
|
||
|
TraceLog.Debug("ExchangeCodeSvc.OnExchangeChangeStatusDbRes reqId {0} ", id);
|
||
|
m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == id);
|
||
|
LitJson.JsonData builder = new LitJson.JsonData();
|
||
|
HttpQueryParams queryParams = new HttpQueryParams(m_request.Http.httpRequest.Url);
|
||
|
|
||
|
Exchange.OnMsgChange(id, builder, m_request.Http.httpResponse, m_request.Http.httpRequest, queryParams, ref res);
|
||
|
m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
TraceLog.Error("ExchangeCodeSvc.OnExchangeChangeStatusDbRes Error Msg {0}", ex.Message);
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
if (m_request != null)
|
||
|
{
|
||
|
m_request.ProcessEnd = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void OnExchangeQueryDbRes(uint serverID, StructPacket packet)
|
||
|
{
|
||
|
ref SSExchangeCodeQueryDbRes res = ref packet.GetMessage<SSExchangeCodeQueryDbRes>();
|
||
|
|
||
|
HttpRequestInfo m_request = null;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
var id = res.ReqId;
|
||
|
TraceLog.Debug("ExchangeCodeSvc.OnExchangeQueryDbRes uid {0} ", id);
|
||
|
m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == id);
|
||
|
LitJson.JsonData builder = new LitJson.JsonData();
|
||
|
HttpQueryParams queryParams = new HttpQueryParams(m_request.Http.httpRequest.Url);
|
||
|
|
||
|
Exchange.OnMsgSelect(id, builder, m_request.Http.httpResponse, m_request.Http.httpRequest, queryParams, ref res);
|
||
|
m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
TraceLog.Error("ExchangeCodeSvc.OnExchangeQueryDbRes Error Msg {0}", ex.Message);
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
if (m_request != null)
|
||
|
{
|
||
|
m_request.ProcessEnd = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void SaveExchangeCodeData(ref ExchangeConfigure one, uint reqId)
|
||
|
{
|
||
|
StructPacket dbPacket = new StructPacket();
|
||
|
dbPacket.Header.Type = (int)SSGameMsgID.ExchangeSaveDbReq;
|
||
|
StructMessageParser<SSExchangeCodeSaveDbReq> parser = new StructMessageParser<SSExchangeCodeSaveDbReq>();
|
||
|
dbPacket.Parser = parser;
|
||
|
ref SSExchangeCodeSaveDbReq req = ref dbPacket.GetMessage<SSExchangeCodeSaveDbReq>();
|
||
|
req.Data.CopyFrom(ref one);
|
||
|
req.Seq = reqId;
|
||
|
OperationServerUtils.GetPacketSender().SendToPlayerOpServer((int)SSGameMsgID.ExchangeSaveDbReq, ref req, 0);
|
||
|
}
|
||
|
}
|
||
|
}
|