📄 u_crs_main.pas
字号:
else begin
c_checkBox_okIn.checked := false;
c_checkBox_okOut.checked := false;
end;
end;
// -- --
procedure Tc_crsForm_main.a_srv_startExecute(Sender: TObject);
var
connType: tunavclProtoType;
begin
// start server
case (c_comboBox_connType.itemIndex) of
//
0:
connType := unapt_UDP;
else
connType := unapt_TCP;
end;
//
if (windows.succeeded(f_server.start(c_edit_port.text, connType))) then begin
//
a_srv_start.enabled := false;
a_srv_formatChoose.enabled := false;
a_srv_stop.enabled := true;
//
addLog('Server was started on ' + choice(connType = unapt_UDP, 'UDP', 'TCP') + ' port #' + c_edit_port.text);
end
else begin
//
addLog('Some problem with server startup (this port is probably used already).');
//
a_srv_start.enabled := true;
end;
//
c_edit_port.enabled := a_srv_start.enabled;
c_comboBox_connType.enabled := a_srv_start.enabled;
end;
// -- --
procedure Tc_crsForm_main.a_srv_stopExecute(Sender: TObject);
begin
// stop server
f_server.stop();
addLog('Server was stopped.');
//
a_srv_stop.enabled := false;
a_srv_start.enabled := true;
a_srv_formatChoose.enabled := true;
//
c_edit_port.enabled := a_srv_start.enabled;
c_comboBox_connType.enabled := a_srv_start.enabled;
end;
// -- --
procedure Tc_crsForm_main.onAC(sender: tObject; connectionId: unsigned; var accept: bool);
var
conn: unaSocksConnection;
remoteIP: string;
begin
conn := f_server.server.getClientConnection(connectionId);
if (nil <> conn) then
try
remoteIP := string(inet_ntoa(conn.paddr.sin_addr)) + ':' + int2str(htons(conn.paddr.sin_port));
addLog('New client/#' + int2str(connectionId) + ' from ' + remoteIP + ' was ' + choice(not accept, 'declined.', 'accepted.'));
//
//
if (accept) then
notifyAddClient(connectionId, remoteIP);
finally
conn.release();
end;
end;
// -- --
procedure Tc_crsForm_main.notifyAddClient(connId: int; const addr: string);
begin
f_clients.add('#' + int2str(connId) + ' ' + addr);
end;
// -- --
procedure Tc_crsForm_main.notifyRemoveClient(connId: int);
begin
f_clients.add('~' + int2str(connId));
end;
// -- --
procedure Tc_crsForm_main.onCE(sender: tObject; connectionId: unsigned; connected: bool);
begin
addLog('Client/#' + int2str(connectionId) + ' is about to be ' + choice(connected, 'connected.', 'disconnected.'));
//
if (not connected) then
notifyRemoveClient(connectionId);
end;
// -- --
procedure Tc_crsForm_main.addLog(const message: string);
begin
f_log.add('[' + DateTimeToStr(now) + '] ' + message);
end;
// -- --
procedure Tc_crsForm_main.onError(sender: tObject; code, info: int);
var
err: string;
begin
case (code) of
c_unaconfserr_unknownDriver:
err := 'SERVER ERROR: Unsupported driver (format tag=' + int2str(info) + ')';
c_unaconfserr_driverNotFound:
err := 'SERVER ERROR: Driver was not found (format tag=' + int2str(info) + ')';
c_unaconfserr_driverFound:
err := 'SERVER INFO: Using installable driver: ' + pChar(info);
else
err := 'Unknown error/info code.';
end;
addLog(err);
end;
// -- --
procedure Tc_crsForm_main.c_splitter_mainCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
var
delta: int;
begin
delta := newSize - c_panel_clients.width;
//
if (0 < delta) then begin
//
if (c_panel_main.width - delta < 400) then begin
//
dec(newSize, 400 - (c_panel_main.width - delta));
delta := newSize - c_panel_clients.width;
end;
//
end;
//
if (0 > delta) then begin
//
if (c_panel_clients.width + delta < 150) then begin
//
inc(newSize, 150 - (c_panel_clients.width + delta));
end;
end;
end;
// -- --
procedure Tc_crsForm_main.formResize(sender: tObject);
begin
if (width - c_panel_clients.width < 410) then
c_panel_clients.width := width - 410;
end;
// -- --
procedure Tc_crsForm_main.a_cln_disconnectExecute(Sender: TObject);
var
i: int;
val: string;
begin
// kick client off
i := c_listBox_clients.itemIndex;
if (0 <= i) then begin
//
val := c_listBox_clients.items[i];
val := system.copy(val, 2, pos(' ', val) - 2);
i := str2intInt(val, 0);
if (0 < i) then
f_server.disconnectClient(unsigned(i));
end;
end;
// -- --
procedure Tc_crsForm_main.c_checkBox_okInClick(Sender: TObject);
var
i: int;
options: unsigned;
begin
// toggle in option
i := c_listBox_clients.itemIndex;
if (0 <= i) then begin
//
options := f_server.clientOptions[i];
if (c_checkBox_okIn.checked) then
options := options or c_unaIPServer_co_inbound
else
options := options and (not c_unaIPServer_co_inbound);
//
f_server.clientOptions[i] := options;
end;
end;
// -- --
procedure Tc_crsForm_main.c_checkBox_okOutClick(Sender: TObject);
var
i: int;
options: unsigned;
begin
// toggle out option
i := c_listBox_clients.itemIndex;
if (0 <= i) then begin
//
options := f_server.clientOptions[i];
if (c_checkBox_okOut.checked) then
options := options or c_unaIPServer_co_outbound
else
options := options and (not c_unaIPServer_co_outbound);
//
f_server.clientOptions[i] := options;
end;
end;
// -- --
procedure Tc_crsForm_main.a_srv_exitExecute(Sender: TObject);
begin
close();
end;
// -- --
procedure Tc_crsForm_main.SelectInstallableDriver1Click(Sender: TObject);
begin
// todo
end;
// -- --
procedure Tc_crsForm_main.About1Click(Sender: TObject);
begin
guiMessageBox('Conference Room Server 1.2.2'#13#10'Copyright (c) 2003-2007 Lake of Soft, Ltd', 'About Conference Server', MB_OK or MB_ICONINFORMATION);
end;
// -- --
procedure Tc_crsForm_main.a_srv_formatChooseExecute(Sender: TObject);
var
format: unavclWavePipeFormatExchange;
//
maxFormatSize: int;
waveFormat: pWaveFormatEx;
//
codec: TunavclWaveCodecDevice;
begin
f_server.getAudioFormat(format);
//
maxFormatSize := getMaxWaveFormatSize();
waveFormat := malloc(maxFormatSize);
//
with (format.r_format.formatOriginal) do
fillPCMFormat(waveFormat^, pcmSamplesPerSecond, pcmBitsPerSample, pcmNumChannels);
//
waveFormat.wFormatTag := format.r_format.formatTag;
//
if (mmNoError(formatChooseAlloc(waveFormat, waveFormat.wFormatTag, waveFormat.nSamplesPerSec, 'Choose audio format', ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT, 0, nil, maxFormatSize, handle))) then begin
//
codec := TunavclWaveCodecDevice.create(nil);
try
codec.setNonPCMFormat(waveFormat^);
//
if (Succeeded(f_server.setAudioFormat(codec.pcm_samplesPerSec, codec.pcm_bitsPerSample, codec.pcm_numChannels, waveFormat.wFormatTag))) then begin
//
f_server.getAudioFormat(format);
//
with (format.r_format.formatOriginal) do
c_label_format.caption := formatTag2str(format.r_format.formatTag) + ': ' + sampling2str(pcmSamplesPerSecond, pcmBitsPerSample, pcmNumChannels);
//
end
else
guiMessageBox(handle, 'This audio format could not be used on server.', 'Audio format error', MB_OK or MB_ICONERROR);
//
finally
freeAndNil(codec);
end;
//
end;
end;
// -- --
procedure Tc_crsForm_main.Button1Click(Sender: TObject);
begin
{$IFDEF DEBUG_REPORT }
c_crs_report.showReport(f_server.selfTest());
{$ENDIF }
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -