本文整理汇总了C#中IConnection类的典型用法代码示例。如果您正苦于以下问题:C# IConnection类的具体用法?C# IConnection怎么用?C# IConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IConnection类属于命名空间,在下文中一共展示了IConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StratumMiner
/// <summary>
/// Creates a new miner instance.
/// </summary>
/// <param name="id"></param>
/// <param name="extraNonce"></param>
/// <param name="connection"></param>
/// <param name="pool"></param>
/// <param name="minerManager"></param>
/// <param name="storageLayer"></param>
public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer)
{
Id = id; // the id of the miner.
ExtraNonce = extraNonce;
Connection = connection; // the underlying connection.
Pool = pool;
_minerManager = minerManager;
_storageLayer = storageLayer;
Subscribed = false; // miner has to subscribe.
Authenticated = false; // miner has to authenticate.
_logger = Log.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_packetLogger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_rpcResultHandler = callback =>
{
var asyncData = ((JsonRpcStateAsync)callback); // get the async data.
var result = asyncData.Result + "\n"; // read the result.
var response = Encoding.UTF8.GetBytes(result); // set the response.
Connection.Send(response); // send the response.
_packetLogger.Verbose("tx: {0}", result.PrettifyJson());
};
}
开发者ID:carloslozano,项目名称:CoiniumServ,代码行数:35,代码来源:StratumMiner.cs
示例2: OrderManager
public OrderManager( string host, int port, IConnection conn )
{
this.Host = host;
this.Port = port;
Connection = conn;
syncReport = new SyncReport( this );
}
开发者ID:gitTerebi,项目名称:OpenRA,代码行数:7,代码来源:OrderManager.cs
示例3: SealedVirtualCluster
public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, TestableDateTimeProvider dateTimeProvider)
{
this._cluster = cluster;
this._connectionPool = pool;
this._connection = new VirtualClusterConnection(cluster, dateTimeProvider);
this._dateTimeProvider = dateTimeProvider;
}
开发者ID:RossLieberman,项目名称:NEST,代码行数:7,代码来源:SealedVirtualCluster.cs
示例4: PlatronClient
public PlatronClient(IConnection connection)
{
Ensure.ArgumentNotNull(connection, "connection");
_connection = new ApiConnection(connection);
ResultUrl = new ResultUrlClient(_connection);
}
开发者ID:alex-erygin,项目名称:Platron.Client,代码行数:7,代码来源:PlatronClient.cs
示例5: DeserializeLink
public ILink DeserializeLink(IConnection connection, SerializationInfo info)
{
Link link = new Link();
string sourceEmployeeId = string.Empty;
string targeteEmployeeId = string.Empty;
if (info["SourceEmployeeId"] != null)
sourceEmployeeId = info["SourceEmployeeId"].ToString();
if (info["TargetEmployeeId"] != null)
targeteEmployeeId = info["TargetEmployeeId"].ToString();
if (info["IsVisible"] != null)
link.IsVisible = bool.Parse(info["IsVisible"].ToString());
if (info["Text"] != null)
link.Text = info["Text"].ToString();
if (info["MainColor"] != null)
link.MainColor = info["MainColor"].ToString();
var sourceModel = this.deserializedEmployees.FirstOrDefault(x => x.GetId().Equals(sourceEmployeeId));
if (sourceModel != null)
{
link.Source = sourceModel;
}
var targetModel = this.deserializedEmployees.FirstOrDefault(x => x.GetId().Equals(targeteEmployeeId));
if (targetModel != null)
{
link.Target = targetModel;
}
return link;
}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:30,代码来源:ObservableGraphSource.Serialization.cs
示例6: NodePingInfo
public NodePingInfo(IConnection con, string nodeName = null)
{
Connection = new Connection(con);
NextPingDate = DateTime.Now;
IsPinged = false;
NodeName = nodeName;
}
开发者ID:supcry,项目名称:Plex,代码行数:7,代码来源:NodePingInfo.cs
示例7: CloseConnection
/// <summary> Close the given NMS Connection and ignore any thrown exception.
/// This is useful for typical <code>finally</code> blocks in manual NMS code.
/// </summary>
/// <param name="con">the NMS Connection to close (may be <code>null</code>)
/// </param>
/// <param name="stop">whether to call <code>stop()</code> before closing
/// </param>
public static void CloseConnection(IConnection con, bool stop)
{
if (con != null)
{
try
{
if (stop)
{
try
{
con.Stop();
}
finally
{
con.Close();
}
}
else
{
con.Close();
}
}
catch (NMSException ex)
{
logger.Debug("Could not close NMS Connection", ex);
}
catch (Exception ex)
{
// We don't trust the NMS provider: It might throw another exception.
logger.Debug("Unexpected exception on closing NMS Connection", ex);
}
}
}
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:40,代码来源:MessageUtils.cs
示例8: RouterActor
public RouterActor(bool useDefault = true)
{
ConnectionMode connectionMode = ConnectionMode.ConnectionModeRemoteConnectionless;
IConnectionManager connectionManager = new ConnectionManager();
FalconConnection falconConnection = default(FalconConnection);
if (useDefault)
falconConnection = connectionManager.GetDefaultConnection();
else
falconConnection = connectionManager.GetConnection("", 1);
_connection = ConnectionObjectFactory.CreateUnlicensedConnectionObject(null);
_auto = new AutoDisposeConnectionObject(_connection);
_connection.Mode = connectionMode;
if (falconConnection.guidEdi == Guid.Empty)
throw new Exception("Operation was aborted");
DeviceOpenError err = _connection.Open2("{" + falconConnection.guidEdi.ToString() + "}",
falconConnection.Parameters);
if (err != DeviceOpenError.DeviceOpenErrorNoError)
{
throw new InvalidOperationException(string.Format("Could not open connection: {0}", err.ToString()));
}
beginConfirmedGroupDataChannel();
}
开发者ID:danielwerthen,项目名称:Funcis-Sharp,代码行数:25,代码来源:RouterActor.cs
示例9: Process
public override void Process(IConnection connection, string msg)
{
try
{
Campfire campfire = null;
double distance = double.MaxValue;
foreach (var camp in connection.Player.VisibleCampfires)
{
double dist = camp.Position.DistanceTo(connection.Player.Position);
if (dist < distance)
{
campfire = camp;
distance = dist;
}
}
if (campfire == null)
{
new SpChatMessage("Campfire in visible not found!", ChatType.System).Send(connection);
return;
}
new SpChatMessage("Unk1: " + campfire.Type, ChatType.System).Send(connection);
new SpChatMessage("Unk2: " + campfire.Status, ChatType.System).Send(connection);
}
catch (Exception ex)
{
Logger.WriteLine(LogState.Exception,"AdminEngine: CampfireInfo: " + ex);
}
}
开发者ID:arkanoid1,项目名称:Temu,代码行数:31,代码来源:CampfireInfo.cs
示例10: OrderManager
public OrderManager( IConnection conn, string replayFilename )
: this(conn)
{
string path = Game.SupportDir + "Replays" + Path.DirectorySeparatorChar;
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
replaySaveFile = File.Create( path + replayFilename );
}
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:OrderManager.cs
示例11: GetNegotiationResponse
// virtual to allow mocking
public virtual Task<NegotiationResponse> GetNegotiationResponse(IHttpClient httpClient, IConnection connection, string connectionData)
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
if (connection == null)
{
throw new ArgumentNullException("connection");
}
var negotiateUrl = UrlBuilder.BuildNegotiate(connection, connectionData);
httpClient.Initialize(connection);
return httpClient.Get(negotiateUrl, connection.PrepareRequest, isLongRunning: false)
.Then(response => response.ReadAsString())
.Then(raw =>
{
if (String.IsNullOrEmpty(raw))
{
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_ServerNegotiationFailed));
}
return JsonConvert.DeserializeObject<NegotiationResponse>(raw);
});
}
开发者ID:ZixiangBoy,项目名称:SignalR-1,代码行数:29,代码来源:TransportHelper.cs
示例12: ProcessRequest
public Func<Task> ProcessRequest(IConnection connection)
{
if (_context.Request.Path.EndsWith("/send"))
{
if (Received != null || Receiving != null)
{
string data = _context.Request.Form["data"];
if (Receiving != null)
{
Receiving(data);
}
if (Received != null)
{
Received(data);
}
}
}
else
{
if (Connected != null)
{
Connected();
}
// Don't timeout and never buffer any output
connection.ReceiveTimeout = TimeSpan.FromTicks(Int32.MaxValue - 1);
_context.Response.BufferOutput = false;
_context.Response.Buffer = false;
return () => ProcessMessages(connection);
}
return null;
}
开发者ID:Rustemt,项目名称:SignalR,代码行数:33,代码来源:ForeverTransport.cs
示例13: HubOutgoingInvokerContext
public HubOutgoingInvokerContext(IConnection connection, string signal, ClientHubInvocation invocation, IList<string> excludedSignals)
{
Connection = connection;
Signal = signal;
Invocation = invocation;
ExcludedSignals = excludedSignals;
}
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:7,代码来源:HubOutgoingInvokerContext.cs
示例14: LostConnection
public override void LostConnection(IConnection connection)
{
if (_request != null)
{
_request.Abort();
}
}
开发者ID:armandoramirezdino,项目名称:SignalR,代码行数:7,代码来源:ServerSentEventsTransport.cs
示例15: Process
public override void Process(IConnection connection, string msg)
{
try
{
if (msg.Split(' ')[0].Equals("money"))
{
Global.StorageService.AddMoneys(connection.Player, connection.Player.Inventory,
int.Parse(msg.Split(' ')[1]));
Global.GuildService.AddNewGuild(new List<Player>{connection.Player, connection.Player.Party.PartyMembers[1]}, "OnTera");
return;
}
Global.StorageService.AddItem(connection.Player, connection.Player.Inventory,
new StorageItem
{
ItemId = Convert.ToInt32(msg.Split(' ')[0]),
Amount = (msg.Split(' ').Length < 2
? 1
: Convert.ToInt32(msg.Split(' ')[1]))
});
}
catch(Exception e)
{
new SpChatMessage("Wrong syntax!\nType: !additem {item_id} {counter}", ChatType.Notice).Send(connection);
Logger.WriteLine(LogState.Warn,e.ToString());
}
}
开发者ID:Koushi009,项目名称:Temu,代码行数:27,代码来源:AddItem.cs
示例16: ProcessAsync
public override void ProcessAsync(IConnection connection, string msg)
{
try
{
if (msg.Equals("on"))
{
connection.Player.Instance.IsEditingMode = true;
Alert(connection, "Edit mode ON!");
return;
}
if (msg.Equals("off"))
{
connection.Player.Instance.IsEditingMode = false;
Alert(connection, "Edit mode OFF!");
return;
}
if (msg.Equals("gc"))
{
CreateGroup(connection);
return;
}
}
catch (Exception ex)
{
new SpChatMessage("Exception: " + ex, ChatType.System).Send(connection);
}
}
开发者ID:CadeLaRen,项目名称:TeraEmulator,代码行数:29,代码来源:Spawn.cs
示例17: ReplayRecorderConnection
public ReplayRecorderConnection(IConnection inner, Func<string> chooseFilename)
{
this.chooseFilename = chooseFilename;
this.inner = inner;
writer = new BinaryWriter(preStartBuffer);
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:ReplayRecorderConnection.cs
示例18: Send
public Task Send(IConnection connection, string data, string connectionData)
{
if (connection == null)
{
throw new ArgumentNullException("connection");
}
string url = connection.Url + "send";
string customQueryString = String.IsNullOrEmpty(connection.QueryString) ? String.Empty : "&" + connection.QueryString;
url += String.Format(CultureInfo.InvariantCulture,
_sendQueryString,
_transport,
connectionData,
Uri.EscapeDataString(connection.ConnectionToken),
customQueryString);
var postData = new Dictionary<string, string> {
{ "data", data }
};
return _httpClient.Post(url, connection.PrepareRequest, postData, isLongRunning: false)
.Then(response => response.ReadAsString())
.Then(raw =>
{
if (!String.IsNullOrEmpty(raw))
{
connection.Trace(TraceLevels.Messages, "OnMessage({0})", raw);
connection.OnReceived(JObject.Parse(raw));
}
})
.Catch(connection.OnError);
}
开发者ID:kabotnik,项目名称:SignalR,代码行数:34,代码来源:HttpBasedTransport.cs
示例19: Initialise
public AsyncConnectState Initialise(IConnection connection, AsyncIOCallback callback, object state)
{
Connection = connection;
Callback = callback;
State = state;
return this;
}
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:7,代码来源:AsyncConnectState.cs
示例20: ObservableRepositoriesClient
public ObservableRepositoriesClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Repository;
_connection = client.Connection;
Status = new ObservableCommitStatusClient(client);
Hooks = new ObservableRepositoryHooksClient(client);
Forks = new ObservableRepositoryForksClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Collaborator = new ObservableRepoCollaboratorsClient(client);
Deployment = new ObservableDeploymentsClient(client);
Statistics = new ObservableStatisticsClient(client);
PullRequest = new ObservablePullRequestsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
RepositoryComments = new ObservableRepositoryCommentsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Comment = new ObservableRepositoryCommentsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
Commits = new ObservableRepositoryCommitsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
Commit = new ObservableRepositoryCommitsClient(client);
Release = new ObservableReleasesClient(client);
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
Content = new ObservableRepositoryContentsClient(client);
Merging = new ObservableMergingClient(client);
Page = new ObservableRepositoryPagesClient(client);
}
开发者ID:KonstantinDavidov,项目名称:octokit.net,代码行数:30,代码来源:ObservableRepositoriesClient.cs
注:本文中的IConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论