public async Task RequestLogout(INetworkPlayer player, IShard shard, ulong EntityID, GamePacket packet) { var resp = new CloseConnection { Unk1 = 0 }; _ = await shard.SendTo(player, ChannelType.Control, resp); }
private void SetSerialConnection() { serialPortConnection = new SerialPortConnection(); serialPortConnection.OnFailedConnection += new EventHandler <EventArgs>(SerialConnectionFailed); serialPortConnection.OnConnectionOpened += new EventHandler <EventArgs>((object sender, EventArgs e) => { this.Text = TITLE + " Serial Connection"; sendColorData = serialPortConnection.Write; closeConnection = serialPortConnection.Close; }); serialPortConnection.OpenConnection(connectionOptions.SerialPort); }
private static void SendResponse(BankCustomer customer, string correlationId) { var bankResponse = new BankResponse() { FullName = customer.FullName, EmailAddress = customer.EmailAddress, Response = true }; var queue = EndPoints.FromBankQueueName; var routingKey = EndPoints.FromBankRoutingKey; var connection = GetConnection.ConnectionGetter(); using var channel = connection.CreateModel(); channel.ExchangeDeclare(exchange: exchangeName, durable: true, type: ExchangeType.Direct); channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null); channel.QueueBind(queue, exchangeName, routingKey); Console.WriteLine("Besked sendt:"); Console.WriteLine("- - - - - - - - - - - - - - -"); Console.WriteLine($"Navn: {bankResponse.FullName}"); Console.WriteLine($"Email: {bankResponse.EmailAddress}"); Console.WriteLine($"CorrelationId: {correlationId}"); Console.WriteLine($"Svar fra banken: {(bankResponse.Response ? "Positivt" : "Negativt")}"); Console.WriteLine("------------------------------"); var message = JsonSerializer.Serialize(bankResponse); var body = Encoding.UTF8.GetBytes(message); var props = channel.CreateBasicProperties(); props.CorrelationId = correlationId; props.Persistent = true; channel.BasicPublish(exchange: exchangeName, routingKey: routingKey, basicProperties: props, body: body); CloseConnection.CloseAll(channel, connection); }
private void SetWebSocketConnection() { webSocketConnction = new WebSocketConnection(); webSocketConnction.OnFailedConnection += new EventHandler <EventArgs>((object s, EventArgs ev) => { this.Text = TITLE + " - no connection available"; }); webSocketConnction.OnConnectionOpened += new EventHandler <EventArgs>((object s, EventArgs ev) => { this.Text = TITLE + " Websocket Connection"; sendColorData = webSocketConnction.Write; closeConnection = webSocketConnction.Close; }); webSocketConnction.OpenConnection(connectionOptions.IP); }
/// <summary> /// Explicitely Rolls Back the specified Transaction, closes the connection & removes transaction form cache. /// </summary> /// <param name="transactionName"></param> public void RollbackTransaction(string transactionName, CloseConnection closeConnection) { try { SqlTransaction objSqlTransaction = (SqlTransaction)transactionCache[transactionName]; if (objSqlTransaction != null) { objSqlTransaction.Rollback(); transactionCache.Remove(transactionName); } if (closeConnection == CloseConnection.YES) { CloseSqlConnection(EDispose.YES); } } catch (Exception objException) { throw new Exception("Error while Rollback! " + objException.ToString(), objException); } }
/// <summary> /// Commits the specified Transaction, closes the connection & removes transaction form cache. /// </summary> /// <param name="transactionName">Name of the transaction to commit.</param> public void CommitTransaction(string transactionName, CloseConnection closeConnection) { try { SqlTransaction objSqlTransaction = (SqlTransaction)transactionCache[transactionName]; if (objSqlTransaction != null) { objSqlTransaction.Commit(); transactionCache.Remove(transactionName); } if (closeConnection == CloseConnection.YES) { CloseSqlConnection(EDispose.YES); } } catch (Exception objException) { throw new Exception("CAN NOT COMMIT! " + objException.ToString(), objException); } }
public NetworkConnection(string server, int port) { _tcpConnectionReady = false; serverName = server; hostPort = port; maxNumberOfConnections = 1; methodToSendRequest = delegate() { Debug.LogError("SendRequest() : delegate not implemented"); }; methodToComputeData = delegate(NetworkData input) { Debug.LogError("ComputeNetworkData() : delegate not implemented"); return(false); }; methodToAbandonConnection = delegate() { Debug.LogError("CloseConnection() : delegate not implemented"); }; }
/// <summary> /// Explicitely Rolls Back the system's default Transaction, closes the connection & removes transaction form cache. /// </summary> public void RollbackTransaction(CloseConnection closeConnection) { RollbackTransaction(DEFAULT_TRANSACTION_NAME, closeConnection); }
/// <summary> /// Commits only default Transaction started by application. /// </summary> public void CommitTransaction(CloseConnection closeConnection) { CommitTransaction(DEFAULT_TRANSACTION_NAME, closeConnection); }
public void RollbackTransaction(string transactionName, CloseConnection closeConnection) { try { SqlTransaction objSqlTransaction = (SqlTransaction)transactionCache[transactionName]; if (objSqlTransaction != null) { objSqlTransaction.Rollback(); transactionCache.Remove(transactionName); } if (closeConnection == CloseConnection.YES) CloseSqlConnection(EDispose.YES); } catch (Exception objException) { throw new Exception("Error while Rollback! " + objException.ToString(), objException); } }
public void RollbackTransaction(CloseConnection closeConnection) { RollbackTransaction(DEFAULT_TRANSACTION_NAME, closeConnection); }
public void CommitTransaction(string transactionName, CloseConnection closeConnection) { try { SqlTransaction objSqlTransaction = (SqlTransaction)transactionCache[transactionName]; if (objSqlTransaction != null) { objSqlTransaction.Commit(); transactionCache.Remove(transactionName); } if (closeConnection == CloseConnection.YES) CloseSqlConnection(EDispose.YES); } catch (Exception objException) { throw new Exception("CAN NOT COMMIT! " + objException.ToString(), objException); } }
public void CommitTransaction(CloseConnection closeConnection) { CommitTransaction(DEFAULT_TRANSACTION_NAME, closeConnection); }