本文整理汇总了C#中Message.GetTransactionKey方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetTransactionKey方法的具体用法?C# Message.GetTransactionKey怎么用?C# Message.GetTransactionKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.GetTransactionKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnReceive
public override void OnReceive(Message message)
{
if (message is Response) {
((Response) message).Request = _transactions[message.GetTransactionKey()];
}
base.OnReceive(message);
}
示例2: HandleBlockwiseAcknowledgement
private void HandleBlockwiseAcknowledgement(Message message)
{
var key = message.GetTransactionKey();
var first = _incomplete[key];
var block1 = message.GetBlockOption(OptionNumber.Block1);
if (block1.M > 0) {
var block = first.GetBlock(block1.Num + 1, block1.Szx);
SendMessageOverLowerLayer(block);
}
else {
_incomplete.Remove(key);
}
}
示例3: Send
public override void Send(Message message)
{
var blockInfo = NegotiateBlockSize(message);
var isBlockwise = message.Payload.Length > BlockOption.DecodeSzx(blockInfo.Szx);
if (isBlockwise) {
if (!message.HasToken) {
message.Token = _tokenManager.AcquireToken();
}
var block = message.GetBlock(blockInfo);
var optionNumber = message is Request ? OptionNumber.Block1 : OptionNumber.Block2;
if (block.GetBlockOption(optionNumber).M > 0) {
_incomplete.Add(message.GetTransactionKey(), message);
}
SendMessageOverLowerLayer(block);
}
else {
SendMessageOverLowerLayer(message);
}
}
示例4: Send
public override void Send(Message message)
{
if (message is Request) {
_transactions[message.GetTransactionKey()] = (Request) message;
}
}
示例5: HandleIncomingPayload
private void HandleIncomingPayload(Message message)
{
var key = message.GetTransactionKey();
var block2 = message.GetBlockOption(OptionNumber.Block2);
if (_incomplete.ContainsKey(key)) {
_incomplete[key].Id = message.Id;
_incomplete[key].AppendPayload(message.Payload);
_incomplete[key].SetOption(block2);
}
else {
_incomplete.Add(key, message);
}
if (block2.M > 0) {
var request = ((Response) message).Request;
var reply = new Request(CodeRegistry.Get, message.IsConfirmable) { Uri = request.Uri, Token = message.Token };
reply.AddOption(new BlockOption(OptionNumber.Block2, block2.Num + 1, 0, block2.Szx));
SendMessageOverLowerLayer(reply);
}
else {
base.OnReceive(_incomplete[key]);
_incomplete.Remove(key);
}
}
示例6: SendBlockwiseResponse
private void SendBlockwiseResponse(Message message)
{
var key = message.GetTransactionKey();
var block2 = message.GetBlockOption(OptionNumber.Block2);
if (!_incomplete.ContainsKey(key)) {
base.OnReceive(message);
}
else {
var first = _incomplete[key];
var block = first.GetBlock(block2.Num, block2.Szx);
if (block != null) {
block.Id = message.Id;
var m = block.GetBlockOption(OptionNumber.Block2).M;
SendMessageOverLowerLayer(block);
if (m == 0) {
_incomplete.Remove(key);
}
}
}
}