/// <summary> /// Клиент пробует подключиться /// </summary> void communicator_OnBind(object source, BindEventArgs e) { SmppBindResp pdu = new SmppBindResp(); pdu.SequenceNumber = e.BindPdu.SequenceNumber; if (!communicator.IsBinded) { //Биндинг соединения AccountBase account = null; try { account = billingprov.GetAccount(e.BindPdu.SystemId, e.BindPdu.Password); billing = new BillingProcessor(account); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_ROK; e.IsBindSucessfull = true; LoggerService.Logger.TraceEvent(TraceEventType.Information, LoggingCatoegory.Protocol.IntValue(), string.Format("Client {0} binded", e.BindPdu.SystemId)); PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Increment(); } catch (Exception ex) { LoggerService.Logger.TraceEvent(TraceEventType.Error, LoggingCatoegory.Protocol.IntValue(), string.Format("Bind failed in fact of account for user {0} cannot be get. Error {1}", e.BindPdu.SystemId, ex.ToString())); pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RBINDFAIL; e.IsBindSucessfull = false; } } else { pdu.CommandStatus = (uint)SmppCommandStatus.ESME_RALYBND; e.IsBindSucessfull = false; } communicator.SendPdu(pdu); }
/// <summary> /// Комманда отсоединения /// </summary> void communicator_OnUnbind(object source, UnbindEventArgs e) { //Отсоединяемся if (communicator.IsBinded && billing != null) { LoggerService.Logger.TraceEvent(TraceEventType.Information, LoggingCatoegory.Protocol.IntValue(), string.Format("Client {0} unbinded", billing.Account.Login)); billing.Account.Dispose(); billing = null; PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Decrement(); } SmppUnbindResp pdu = new SmppUnbindResp(); pdu.SequenceNumber = e.UnbindPdu.SequenceNumber; pdu.CommandStatus = (uint)SmppCommandStatus.ESME_ROK; }
void communicator_OnClose(object source, EventArgs e) { //Записать, что сокет закрылся PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Decrement(); }
void communicator_Disposed(object sender, EventArgs e) { //Сокет уничтожен PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Decrement(); }
void communicator_OnError(object source, CommonErrorEventArgs e) { //Ошибка работы комуникатора PerformanceCountersService.GetCounter(CONNECTION_COUNTER_NAME).Decrement(); }