ssh chat:@www.vitalipom.com ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ (์ด์ ์ฌ์ฉ์ ์ด๋ฆ์ด ์์ต๋๋ค!)
Curses ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ํ๋ก๊ทธ๋๋จธ๋ฅผ ์ํ SSH ์ฑํ ์ ๋ง๋ค์์ต๋๋ค.
์ ๋ฐ, ์ ๋ฐ, ์ ๋ฅผ ๋ฐฉ๋ฌธํด์ฃผ์ธ์. ์ฐ๋ฆฌ ์ง์ ์๋ ์๋ฒ, ์ธํฐ๋ท์ ์ฐ๊ฒฐ๋ ์ค์ ์๋ฒ ์ปดํจํฐ์ ๋๋ค. ์ ๋ ์ต๊ทผ์ ํผ์ ์๋์คํฌ๋กค ๊ตฌํํ๋๋ฐ ์ด ์์ค์ฝ๋๋ ๊ณต์ ํ ๊ฒ์. ๋ฐฉ๋ฌธํ์ฌ ๋ฉ์์ง๋ฅผ ๋จ๊ธฐ๊ณ ์ ์ ์ฅ์์ ๋ณํ๋ฅผ ๋จ๊ฒจ์ฃผ์ธ์.
์ฌ๊ธฐ์์ ์์ค ์ฝ๋๋ฅผ ์ฐพ์ผ์ญ์์ค.
https://github.com/VitaliPom/chatapp/blob/master/perl.pl
๊ทธ๋ฆฌ๊ณ CMD์์ ํ ์ค ๋ช ๋ น์ผ๋ก ์ฑํ ์ ๋ค์ด๊ฐ๋๋ค.
ssh chat:@www.vitalipom.com
๊ฐ์ฌํฉ๋๋ค.
๋นํ๋ฆฌ ํฌ๋ง๋์ธ ํค
ํธ์ง: ~~~~ ์์ค ์ฝ๋ ~~~~
#! /home/linuxbrew/.linuxbrew/opt/[email protected]/bin/perl -w
use strict;
use Curses;
use Curses::UI;
use Curses::UI::Common;
# create a new C::UI object
my $key_up = 0;
my $cui = Curses::UI->new( -clear_on_exit => 1,
);
my $win = $cui->add('window_id', 'Window');
my $height = `tput rows`;
$height-=1;
my $textentry = $win->add(
'mytextentry', 'TextEntry',
-y => $height,
-text => 'Username: '
);
my $SERVER = "192.168.1.13/chat.php";
my $USERNAME = "";
my $text = `curl $SERVER`;
$text =~ s#""#"#g;
$text =~ s#``#`#g;
$text =~ s#''#'#g;
my $textviewer = $win->add(
'mytextviewer', 'TextViewer',
-text => $text,
-vscrollbar => 1
);
$textentry->focus();
#$text = $textentry->get();
#$textentry->set_routine('loose-focus',"\r");
#$cui->set_routine('none',KEY_UP);
#$cui->set_routine('none',KEY_DOWN);
$cui->set_binding( sub {
$text = $textentry->get();
$text =~ s#"#""#g;
$text =~ s#`#``#g;
$text =~ s#'#''#g;
if(not defined $text or $text eq ""){
return;
}
my $is_log = 0;
if($USERNAME eq ""){
my $tmp_username = $text;
if($tmp_username =~ /Username:\s*/){
$tmp_username =~ s#Username:\s*##;
if($tmp_username ne ""){
$USERNAME = $tmp_username;
$USERNAME =~ s#"##g;
$USERNAME =~ s#`##g;
$USERNAME =~ s#'##g;
$text = "$USERNAME has logged in!";
$is_log = 1;
}
}
}
$USERNAME =~ s#"#""#g;
$USERNAME =~ s#`#``#g;
$USERNAME =~ s#'#''#g;
if($USERNAME ne ""){
if(not $is_log){
$text = $USERNAME . ": " . $text;
}
my $new_text = $text;
$USERNAME =~ s#"#""#g;
$USERNAME =~ s#`#``#g;
$USERNAME =~ s#'#''#g;
$new_text =~ s#$USERNAME: ##;
$new_text =~ s#Username:\s*##;
if($new_text eq ":q"){
exit 0;
}
`curl $SERVER -d "message=$text"`;
$text = `curl $SERVER`;
$text =~ s#""#"#g;
$text =~ s#``#`#g;
$text =~ s#''#'#g;
$textviewer->text($text);
$textentry->text("");
}else{
$textentry->text("Username: ");
}
}, KEY_ENTER());
#$cui->set_binding( sub {
# $text = `curl $SERVER`;
# $textviewer->text($text);
#
# $cui->draw(1);
#
## $textviewer->{-yscrpos}++;
# $textviewer->layout_content();
## $textentry->focus();
#
# }, "5" );
$cui->set_timer(
'timer',
sub {
$text = `curl $SERVER`;
$text =~ s#""#"#g;
$text =~ s#``#`#g;
$text =~ s#''#'#g;
$textviewer->text($text);
# $textentry->focus();
if($key_up == 0){
for(my $i = 0; $i<2000; $i++){
$textviewer->cursor_down()
}
}
$cui->draw(1);
return;
},
1,
);
for(my $i =0; $i<2000; $i++){
$textviewer->cursor_down();
}
$textviewer->set_binding( sub {
$key_up--;
$textviewer->cursor_up()
}, KEY_UP() );
$textentry->set_binding( sub {
$key_up--;
$textviewer->focus();
$textviewer->cursor_up();
$textentry->focus();
}, KEY_UP() );
$textentry->set_binding( sub {
if($key_up < 0){
$key_up++;
}
$textviewer->focus();
$textviewer->cursor_down();
$textentry->focus();
}, KEY_DOWN() );
$textviewer->set_binding( sub {
if($key_up < 0){
$key_up++;
}
$textviewer->cursor_down()
}, KEY_DOWN() );
$cui->set_binding( sub {exit 0;}, "\e" );
$cui->mainloop;
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(ssh chat:@www.vitalipom.com ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ๐ฅ (์ด์ ์ฌ์ฉ์ ์ด๋ฆ์ด ์์ต๋๋ค!)), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://dev.to/vitalipom/ssh-chat-www-vitalipom-com-now-with-usernames-1d4bํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ ์ธ ๋ฐ๊ฒฌ์ ์ ๋ (Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค