public async Task <IActionResult> CheckPaidHistory() { byte[] hasharray = HttpContext.Session.Get("HashHistory"); Google.Protobuf.ByteString RHash = Google.Protobuf.ByteString.CopyFrom(hasharray); Lightning lnd = GetLightning(); await lnd.ResponseStreaming(RHash); string returnMessage = "<ul>\n"; for (int i = _myData.GetAppData.MessageStack.Count - 1; i >= 0; i--) { returnMessage += "<li>" + _myData.GetAppData.MessageStack.ToArray()[i] + "</li>\n"; } returnMessage += "</ul>"; _myData.SaveLog("View Messages"); try { System.IO.File.Delete(Encoding.ASCII.GetString(HttpContext.Session.Get("QRFilenameHistory"))); } catch { } return(new JsonResult(returnMessage)); }
public string GetServer(string ServiceName, bool needWatch = true) { Google.Protobuf.ByteString key = Google.Protobuf.ByteString.CopyFromUtf8($"/EtcdDiscovery/{ServiceName}"); var req = new Etcdserverpb.RangeRequest() { Key = key }; var result = _client.GetAsync(ServiceName).Result; if (result.Kvs != null && result.Kvs.Count > 0) { lock (klst) { if (needWatch && klst.Contains(key)) { klst.Add(key); } } return(result.Kvs[0].Value.ToStringUtf8()); } else { return(null); } }
private async Task SignBlockAsync(Block block) { block.Header.SignerPubkey = ByteString.CopyFrom(await _accountService.GetPublicKeyAsync()); var signature = await _accountService.SignAsync(block.GetHash().DumpByteArray()); block.Header.Signature = ByteString.CopyFrom(signature); }
/// <summary> /// 处理玩家提交快照数据 /// </summary> /// <param name="gcNID">玩家ID</param> /// <param name="frame">快照的所在的帧数</param> /// <param name="data">快照数据</param> internal void HandleCommitSnapshot(ulong gcNID, int frame, Google.Protobuf.ByteString data) { if (this._snapshotMgr.Commit(frame, gcNID, data)) { this.DecodeSnapshot(data); } }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { Google.Protobuf.ByteString gen_ret = new Google.Protobuf.ByteString(); translator.Push(L, gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <System.Collections.Generic.List <byte> >(L, 2)) { System.Collections.Generic.List <byte> _list = (System.Collections.Generic.List <byte>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <byte>)); Google.Protobuf.ByteString gen_ret = new Google.Protobuf.ByteString(_list); translator.Push(L, gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { byte[] _bytes = LuaAPI.lua_tobytes(L, 2); Google.Protobuf.ByteString gen_ret = new Google.Protobuf.ByteString(_bytes); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to Google.Protobuf.ByteString constructor!")); }
static ImageReply CreateErrorReply(string error) { Google.Protobuf.ByteString image = Google.Protobuf.ByteString.CopyFrom(new byte[0]); return(new ImageReply() { Error = error, FullImage = image, SmallImage = image }); }
public void ExtractByteArrayOptimizedTest(int size) { byte[] data = Enumerable.Range(0, size).Select(o => (byte)(o % 256)).ToArray(); Google.Protobuf.ByteString btStr = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(data); var extractedArray = ProtoBufByteStringHelper.ExtractByteArrayOptimized(btStr); Assert.Equal(data, extractedArray); if (ProtoBufByteStringHelper.CanExtractByteArrayOptimized() && ProtoBufByteStringHelper.CanCreateFromByteArrayOptimized() && data.Length >= ProtoBufByteStringHelper.ExtractObjectIndexFromMemoryWithReflectionThreshold) Assert.True(object.ReferenceEquals(data, extractedArray)); }
static int _s_set_bytes(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Google.Protobuf.ByteString gen_to_be_invoked = (Google.Protobuf.ByteString)translator.FastGetCSObj(L, 1); gen_to_be_invoked.bytes = LuaAPI.lua_tobytes(L, 2); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(0); }
static int _g_get_IsEmpty(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Google.Protobuf.ByteString gen_to_be_invoked = (Google.Protobuf.ByteString)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, gen_to_be_invoked.IsEmpty); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(1); }
static int _m_CopyFrom_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count >= 0 && (LuaTypes.LUA_TNONE == LuaAPI.lua_type(L, 1) || LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1))) { byte[] _bytes = translator.GetParams <byte>(L, 1); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.CopyFrom(_bytes); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { byte[] _bytes = LuaAPI.lua_tobytes(L, 1); int _offset = LuaAPI.xlua_tointeger(L, 2); int _count = LuaAPI.xlua_tointeger(L, 3); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.CopyFrom(_bytes, _offset, _count); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Text.Encoding>(L, 2)) { string _text = LuaAPI.lua_tostring(L, 1); System.Text.Encoding _encoding = (System.Text.Encoding)translator.GetObject(L, 2, typeof(System.Text.Encoding)); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.CopyFrom(_text, _encoding); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to Google.Protobuf.ByteString.CopyFrom!")); }
static StackObject *ToByteArray_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.ByteString instance_of_this_method = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.ToByteArray(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary> /// Create a string in JSON format containing the representation /// of the image to be sent to the CPU-based model. /// </summary> /// <returns> /// A string containing the JSON representation of the image to be /// processed by the model. /// </returns> private string MakeImageJson(Google.Protobuf.ByteString image) { DateTime then = DateTime.Now; try { StringBuilder sb = new StringBuilder("{\"img\": ["); // Rehydrate the .png file as a Bitmap using (MemoryStream stream = new MemoryStream(image.ToByteArray())) using (Bitmap bitmap = new Bitmap(stream)) { int width = bitmap.Width; int height = bitmap.Height; for (int i = 0; i < height; i++) { sb.Append('['); for (int j = 0; j < width; j++) { var pixel = bitmap.GetPixel(j, i); sb.AppendFormat("[{0},{1},{2}]", pixel.R, pixel.G, pixel.B); if (j < width - 1) { sb.Append(','); } } sb.Append(']'); if (i < height - 1) { sb.Append(','); } } sb.Append("]}"); } return(sb.ToString()); } catch (Exception ex) { Console.WriteLine("Error converting small image to JSON:"); Console.WriteLine(ex); return(""); } finally { // TODO: timing imageToJsonDuration = DateTime.Now - then; } }
static ImageReply OnImageRequestReceived(ImageRequest request) { Console.WriteLine($" Received request for camera:{request.CameraHardwareId}"); lock (SimpleLock) { try { // This naive implementation uses integers as cameraHardwareId bool parsedOk = int.TryParse(request.CameraHardwareId, out int cameraHardwareId); if (!parsedOk) { return(CreateErrorReply("Camera hardware Id must be an integer for this version of CameraServer")); } // Get the requested camera bool foundCamera = g_cameras.TryGetValue(cameraHardwareId, out VideoCapture camera); if (!foundCamera) { return(CreateErrorReply("Requested camera ID " + cameraHardwareId.ToString() + " not found")); } // Grab a frame Mat frame = new Mat(); camera.Read(frame); if (!frame.Empty()) { byte[] fullImageBytes = new byte[0]; Cv2.ImEncode(".jpeg", frame, out fullImageBytes); Google.Protobuf.ByteString fullImage = Google.Protobuf.ByteString.CopyFrom(fullImageBytes); Mat smallFrame = new Mat(); Cv2.Resize(frame, smallFrame, new Size(300, 300), 0, 0, InterpolationFlags.Area); byte[] smallImageBytes = new byte[0]; Cv2.ImEncode(".png", smallFrame, out smallImageBytes); Google.Protobuf.ByteString smallImage = Google.Protobuf.ByteString.CopyFrom(smallImageBytes); return(new ImageReply() { Error = string.Empty, FullImage = fullImage, SmallImage = smallImage }); } else { return(CreateErrorReply("Empty frame from camera ID " + cameraHardwareId.ToString())); } } catch (Exception ex) { return(CreateErrorReply("Error while processing frame for camera ID " + request.CameraHardwareId + ": " + ex.Message)); } } }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Byte[] @bytes = (System.Byte[]) typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = new Google.Protobuf.ByteString(@bytes); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *get_Length_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.ByteString instance_of_this_method = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Length; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
public async Task <IActionResult> CheckPaidChannel() { byte[] hasharray = HttpContext.Session.Get("HashChannel"); Google.Protobuf.ByteString RHash = Google.Protobuf.ByteString.CopyFrom(hasharray); Lightning lnd = GetLightning(); await lnd.ResponseStreaming(RHash); try { Email.WriteEmail("*****@*****.**", "*****@*****.**", "Open a channel", Encoding.ASCII.GetString(HttpContext.Session.Get("BuyChannel"))); System.IO.File.Delete(Encoding.ASCII.GetString(HttpContext.Session.Get("QRFilenameChannel"))); } catch { } return(new JsonResult(new { paid = "paid.jpg", message = "Channel opening requested" })); }
static StackObject *ComputeBytesSize_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.ByteString @value = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = Google.Protobuf.CodedOutputStream.ComputeBytesSize(@value); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
static StackObject *WriteBytes_11(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.ByteString @value = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.CodedOutputStream instance_of_this_method = (Google.Protobuf.CodedOutputStream) typeof(Google.Protobuf.CodedOutputStream).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.WriteBytes(@value); return(__ret); }
static StackObject *CheckNotNull_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.ByteString @value = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = Google.Protobuf.ProtoPreconditions.CheckNotNull <Google.Protobuf.ByteString>(@value, @name); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary> /// 数据不同步的回调函数 /// </summary> /// <param name="gcNID">不同步的玩家ID</param> /// <param name="frame">不同步的帧</param> /// <param name="data1">正常数据</param> /// <param name="data2">异常数据</param> internal void OnOutOfSync(ulong gcNID, int frame, Google.Protobuf.ByteString data1, Google.Protobuf.ByteString data2) { BSUser user = BS.instance.userMgr.GetUser(gcNID); //发送不同步的数据 Protos.BS2GC_OutOfSync outOfSync = ProtoCreator.Q_BS2GC_OutOfSync(); outOfSync.Frame = frame; outOfSync.Data1 = data1; outOfSync.Data2 = data2; BS.instance.netSessionMgr.Send(user.gcSID, outOfSync); //通知CS玩家离开战场 Protos.BS2CS_KickUser kickUser = ProtoCreator.Q_BS2CS_KickUser(); kickUser.GcNID = gcNID; kickUser.Reason = Protos.BS2CS_KickUser.Types.Reason.OutOfSync; BS.instance.netSessionMgr.Send(SessionType.ServerB2CS, kickUser); //断开玩家连接 BS.instance.netSessionMgr.CloseSession(user.gcSID, "different snapshot crc32 value"); }
/// <summary> /// 把帧行为保存到历史列表 /// 填充后会清空当前帧的帧行为 /// 战场线程调用 /// </summary> internal void Save(int frame) { this._frameBuffer.Write(( byte )0); byte count = 0; lock (this._gcNIDToAction) { foreach (KeyValuePair <ulong, FrameAction> kv in this._gcNIDToAction) { FrameAction frameAction = kv.Value; frameAction.Serialize(this._frameBuffer); frameAction.Clear(); ++count; } } this._frameBuffer.Write(0, count); Google.Protobuf.ByteString data = Google.Protobuf.ByteString.CopyFrom(this._frameBuffer.GetBuffer(), 0, this._frameBuffer.length); this._frameBuffer.Clear(); this._histroy[frame] = data; }
static int _m_FromBytes_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { byte[] _bytes = LuaAPI.lua_tobytes(L, 1); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.Unsafe.FromBytes(_bytes); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_GetBuffer_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { Google.Protobuf.ByteString _bytes = (Google.Protobuf.ByteString)translator.GetObject(L, 1, typeof(Google.Protobuf.ByteString)); byte[] gen_ret = Google.Protobuf.ByteString.Unsafe.GetBuffer(_bytes); LuaAPI.lua_pushstring(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public async Task ResponseStreaming(Google.Protobuf.ByteString RHash) { var request = new InvoiceSubscription(); PaymentHash paymentHash = new PaymentHash(); paymentHash.RHash = RHash; using (var call = client.SubscribeInvoices(request)) { while (await call.ResponseStream.MoveNext()) { var invoice = call.ResponseStream.Current; Console.WriteLine(invoice.ToString()); var lookup = client.LookupInvoice(paymentHash); if (lookup.Settled) { break; } } } }
static int _m_CopyFromUtf8_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { string _text = LuaAPI.lua_tostring(L, 1); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.CopyFromUtf8(_text); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public async Task <IActionResult> CheckPay() { byte[] hasharray = HttpContext.Session.Get("Hash"); Google.Protobuf.ByteString RHash = Google.Protobuf.ByteString.CopyFrom(hasharray); Lightning lnd = GetLightning(); await lnd.ResponseStreaming(RHash); _myData.GetAppData.Message = _myData.GetAppData.MessageTemp; _myData.GetAppData.MessageStack.Enqueue(_myData.GetAppData.Message); _myData.GetAppData.MessageStack.Dequeue(); _myData.Save(); try { System.IO.File.Delete(Encoding.ASCII.GetString(HttpContext.Session.Get("QRFilename"))); } catch { } return(new JsonResult(new { paid = "paid.jpg", message = _myData.GetAppData.MessageTemp })); }
static int _m_ToByteString_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { Google.Protobuf.IMessage _message = (Google.Protobuf.IMessage)translator.GetObject(L, 1, typeof(Google.Protobuf.IMessage)); Google.Protobuf.ByteString gen_ret = Google.Protobuf.MessageExtensions.ToByteString(_message); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static StackObject *op_Inequality_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Google.Protobuf.ByteString @rhs = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); Google.Protobuf.ByteString @lhs = (Google.Protobuf.ByteString) typeof(Google.Protobuf.ByteString).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = lhs != rhs; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
static int _m_FromStream_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { System.IO.Stream _stream = (System.IO.Stream)translator.GetObject(L, 1, typeof(System.IO.Stream)); Google.Protobuf.ByteString gen_ret = Google.Protobuf.ByteString.FromStream(_stream); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public List <ImageFeature> Process(Google.Protobuf.ByteString image) { string imageJson = MakeImageJson(image); if (imageJson != null) { CpuModelResponse response = InvokeCpuModel(imageJson); if (response != null) { List <ImageFeature> result = new List <ImageFeature>(); for (int i = 0; i < response.classes.Length; i++) { ImageFeature feature = new ImageFeature(response.classes[i], response.scores[i], response.bboxes[i]); result.Add(feature); } return(result); } } return(null); }