当前位置: 首页>>代码示例>>C#>>正文


C# Connection.Close方法代码示例

本文整理汇总了C#中System.Net.Connection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Close方法的具体用法?C# Connection.Close怎么用?C# Connection.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Connection的用法示例。


在下文中一共展示了Connection.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Listener_OnConnect

 private void Listener_OnConnect(Connection<Session> Client)
 {
     if (!IsListening)
     {
         Client.Close();
         return;
     }
     Logger.Debug("Listener_OnConnect");
     Session session = new Session(Client, this);
     //分配对战端
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:11,代码来源:RoomServer.cs

示例2: HandleCommandException

 protected internal virtual void HandleCommandException(Connection connection, Exception ex)
 {
     /* On error, just close the connection, descendand classes may implement 
      * additional/different behavior */
     connection.Close();
 }
开发者ID:nolith,项目名称:internetpack,代码行数:6,代码来源:CommandBasedServer.cs

示例3: ApiListener_OnConnect

 private void ApiListener_OnConnect(Connection<DuelServer> Client)
 {
     if (Client == null) return;
     if (!IsListening)
     {
         Client.Close();
         return;
     }
     DuelServer server = new DuelServer(this, Client);
     Client.Tag = server;
     lock (DuelServers)
     {
         DuelServers.Add(server);
     }
     Logger.Debug("duel server connected.");
 }
开发者ID:247321453,项目名称:YgoServer,代码行数:16,代码来源:RoomServer.cs

示例4: MessageReceived


//.........这里部分代码省略.........
                        }
                    }
                    else
                    {
                        body = string.Empty;
                    }
                }
            }
            catch
            {
                // TODO: Logging etc.
                return ContinuationAction.Continue; // Allow other plugins to execute.
            }

            // TODO: Get data from the body somehow.
            // You can also look into attachments for e.g. InfoPath forms:
            // e.ReceivedInformation.Message.Attachments

            try
            {
                var con = new Connection();
                var cs = new ConnectionSetup();
                cs.ParseConnectionString(_k2ServerConnectionString);

                try
                {
                    Exception lastException = null;
                    con.Open(cs);

                    // AlternateIdentities are identities with the same email
                    // address, most likely due badly configured claims.
                    for (var i = 0; i < e.AlternateIdentities.Length; i++)
                    {
                        var alt = e.AlternateIdentities[i];
                        string fqn;

                        // Search for a FQN in the identity.
                        if (alt.TryGetValue("Fqn", out fqn))
                        {
                            try
                            {
                                con.RevertUser();
                                con.ImpersonateUser(fqn);

                                var pi = con.CreateProcessInstance(workflowName);
                                // TODO: Set data in the workflow.
                                con.StartProcessInstance(pi);

                                // Tell the user the workflow was started.
                                _destination.ReplyTo(e.ReceivedInformation.Message, new MessageBodyReader("text/plain", "Workflow started"), replyExtended);

                                e.ReceivedInformation.Commit(); // Indicate we were able to handle the message.
                                return ContinuationAction.Halt; // Stop other plugins from executing.
                            }
                            catch (Exception ex)
                            {
                                // TODO: Logging etc.
                                // This isn't nessecarily a complete failure,
                                // one of the other alternate identities may be
                                // able to action this.
                                lastException = ex;
                            }
                        }
                    }

                    string message;
                    if (lastException != null)
                    {
                        // Identities exist, but the user likely doesn't have rights.
                        message = lastException.ToString();
                    }
                    else
                    {
                        // No identities exist.
                        message = "Could not find a K2 user for your email address.";
                    }

                    message = "The workflow could not be started: " + message;

                    // Respond with the error.
                    _destination.ReplyTo(e.ReceivedInformation.Message, new MessageBodyReader("text/plain", message), replyExtended);

                    e.ReceivedInformation.Commit(); // Indicate we were able to handle the message.
                    return ContinuationAction.Halt; // Stop other plugins from executing.
                }
                finally
                {
                    if (con != null)
                    {
                        con.Close();
                        con.Dispose();
                    }
                }
            }
            catch
            {
                // TODO: Logging etc.
                return ContinuationAction.Continue; // Allow other plugins to execute.
            }
        }
开发者ID:jonnoking,项目名称:Samples.MessageBus.ProcessStarter,代码行数:101,代码来源:StartProcessListener.cs


注:本文中的System.Net.Connection.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。