자유게시판입니다.

Private Sub tcp_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    
    '<=========================================================================================================>
    '
    '                         |     N G D       MESSINGER SERVER SUB ROOTINE            |
    '
    '                          =========================================================
    '
    '                                                                              소스의 무단복제를 금지합니다.
    '
    '<--------------------------------------------------------------------------------------------------------->
    
    Dim datas As String
    tcp(Index).GetData datas
    loglist.AddItem "Accept Command ->" & "SKID : " & Index & " -> " & datas
    loglist.Selected(loglist.ListCount - 1) = True
    loglist.Selected(loglist.ListCount - 1) = False
    la.Caption = la.Caption + 1
    
        Select Case Mid(datas, 1, 3)
            Case "log"
                loglist.AddItem "Unindentify User " & Index & " Command -> " & datas & " (로그인요청)"
                loglist.Selected(loglist.ListCount - 1) = True
                loglist.Selected(loglist.ListCount - 1) = False
                Dim id As String
                Dim pass As String
                Dim skid As Integer
                Dim tempi As Integer
                Dim tempok As Boolean
                Dim idok As Boolean
                tempi = 5
                        
                For j = 5 To Len(datas)
                    If Mid(datas, j, 1) <> ":" Then
                        tempi = tempi + 1
                    Else
                        id = Mid(datas, 5, tempi - 5)
                        pass = Mid(datas, tempi + 1, Len(datas))
                        skid = Index
                        loglist.AddItem "Unindentify User " & Index & " Login Command -> ID : " & id & "   Pass : " & pass & "   SK : " & skid
                        loglist.Selected(loglist.ListCount - 1) = True
                        loglist.Selected(loglist.ListCount - 1) = False
                        
                        For mm = 0 To onlist.ListCount - 1
                        If id = onlist.List(mm) Then
                        If tcp(Index).State = 7 Then
                            tcp(Index).SendData "log:da"
                            DoEvents
                            loglist.AddItem "Send Command ->" & "SKID : " & p_user(j, 4) & " -> " & "log:da"
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            ls.Caption = ls.Caption + 1
                            loglist.AddItem "다중접속 ID : " & id & "     - 로그인 거부"
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            Exit Sub
                        End If
                        End If
                        Next
                        
                        For i = 1 To p_cnt
                            If id = p_user(i, 1) Then
                                If pass = p_user(i, 2) Then
                                If tcp(Index).State = 7 Then
                                        tcp(Index).SendData "log:ok:" & p_user(i, 8) & ":"
                                        DoEvents
                                        loglist.AddItem "Send Command ->" & "SKID : " & p_user(j, 4) & " -> " & "log:ok"
                                        loglist.Selected(loglist.ListCount - 1) = True
                                        loglist.Selected(loglist.ListCount - 1) = False
                                        ls.Caption = ls.Caption + 1
                                        tempok = True
                                        p_user(i, 4) = skid
                                        p_user(i, 7) = "04"
                                        p_user(i, 6) = Date & " - " & Time
                                End If
                                End If
                            End If
                        Next
                        
                        If tempok = True Then
                            loglist.AddItem "SKID " & skid & " User " & id & " is Logon now." & Date & " - " & Time
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            log_user = log_user + 1
                            sb.Panels.Item(2).Text = "Login User : " & onlist.ListCount
                            onlist.AddItem id
                            For k = 0 To offlist.ListCount - 1
                                If offlist.List(k) = id Then
                                    offlist.RemoveItem (k)
                                End If
                            Next
                        Else
                        If tcp(Index).State = 7 Then
                            loglist.AddItem "SKID " & skid & " User " & id & " is Not Regist User. 허가거부"
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            tcp(Index).SendData "log:no"
                            DoEvents
                            loglist.AddItem "Send Command ->" & "SKID : " & p_user(j, 4) & " -> " & "log:no"
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            ls.Caption = ls.Caption + 1
                        End If
                        End If
                    End If
                Next
                
            Case "nid"
                    Dim iddd As String
                    Dim idoks As Boolean
                    
                    iddd = Mid(datas, 5, Len(datas) - 4)
                    idoks = True
                    For i = 1 To p_cnt
                        If iddd = p_user(i, 1) Then
                            idoks = False
                        End If
                    Next
                    
                    If idoks = True Then
                    If tcp(Index).State = 7 Then
                        tcp(Index).SendData "nid:ok"
                        DoEvents
                        loglist.AddItem "Send Command ->" & "SKID : " & p_user(Index, 4) & " -> " & "nid:ok"
                        loglist.Selected(loglist.ListCount - 1) = True
                        loglist.Selected(loglist.ListCount - 1) = False
                        ls.Caption = ls.Caption + 1
                    End If
                    ElseIf idoks = False Then
                        If tcp(Index).State = 7 Then
                        tcp(Index).SendData "nid:no"
                        DoEvents
                        loglist.AddItem "Send Command ->" & "SKID : " & p_user(Index, 4) & " -> " & "nid:no"
                        loglist.Selected(loglist.ListCount - 1) = True
                        loglist.Selected(loglist.ListCount - 1) = False
                        ls.Caption = ls.Caption + 1
                        End If
                    End If
                    
            Case "new"
                    Dim new_id As String
                    Dim new_name As String
                    Dim new_sex As String
                    Dim new_pass As String
                    Dim new_email As String
                    Dim new_birth As String
                    Dim new_job As String
                    Dim new_age As String
                    Dim new_text As String
                    Dim new_count As Integer
                    
                    new_count = 1
                    new_text = Mid(datas, 5, Len(datas) - 4)
                    
                    For i = 1 To Len(new_text)
                        If Mid(new_text, i, 1) = ":" Then
                            new_count = new_count + 1
                        End If
                        
                        Select Case new_count
                            Case 1
                                new_id = new_id & Mid(new_text, i, 1)
                                
                            Case 2
                                new_name = new_name & Mid(new_text, i, 1)
                                
                            Case 3
                                new_sex = new_sex & Mid(new_text, i, 1)
                                
                            Case 4
                                new_pass = new_pass & Mid(new_text, i, 1)
                                
                            Case 5
                                new_email = new_email & Mid(new_text, i, 1)
                            
                            Case 6
                                new_birth = new_birth & Mid(new_text, i, 1)
                                
                            Case 7
                                new_job = new_job & Mid(new_text, i, 1)
                                
                            Case 8
                                new_age = new_age & Mid(new_text, i, 1)
                                
                        End Select
                    Next
                    
                    new_name = Mid(new_name, 2, Len(new_name) - 1)
                    new_sex = Mid(new_sex, 2, Len(new_sex) - 1)
                    new_pass = Mid(new_pass, 2, Len(new_pass) - 1)
                    new_email = Mid(new_email, 2, Len(new_email) - 1)
                    new_birth = Mid(new_birth, 2, Len(new_birth) - 1)
                    new_job = Mid(new_job, 2, Len(new_job) - 1)
                    new_age = Mid(new_age, 2, Len(new_age) - 1)
                    
                    p_cnt = p_cnt + 1
                    
                    Open fp & "data\user.cot" For Output As #1
                        Print #1, p_cnt - 2
                    Close #1
                    
                    Dim old_cnt As Integer
                    old_cnt = Mid(sb.Panels.Item(3), Len(sb.Panels.Item(3)), 1)
                    odl_cnt = old_cnt + 1
                    
                    sb.Panels.Item(3).Text = "Join User : " & p_cnt - 2
                    
                    p_user(p_cnt - 2, 1) = new_id
                    p_user(p_cnt - 2, 3) = new_name
                    p_user(p_cnt - 2, 9) = new_sex
                    p_user(p_cnt - 2, 2) = new_pass
                    p_user(p_cnt - 2, 5) = new_email
                    p_user(p_cnt - 2, 11) = new_birth
                    p_user(p_cnt - 2, 12) = new_job
                    p_user(p_cnt - 2, 13) = new_age
                    
                    offlist.AddItem new_id
                    
                    Open fp & "data\user.pdt" For Output As #1
                        For i = 1 To p_cnt - 2
                            Write #1, p_user(i, 1)
                            Write #1, p_user(i, 2)
                            Write #1, p_user(i, 3)
                            Write #1, p_user(i, 5)
                            Write #1, p_user(i, 8)
                            Write #1, p_user(i, 9)
                            Write #1, p_user(i, 11)
                            Write #1, p_user(i, 12)
                            Write #1, p_user(i, 13)
                            Write #1, p_user(i, 14)
                        Next
                    Close #1
                    If tcp(Index).State = 7 Then
                    loglist.AddItem "Creat User -> " & new_id & " at " & Data & " - " & Time
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    
                    tcp(Index).SendData "new:ok"
                    DoEvents
                    loglist.AddItem "SKID (" & Index & ")   ->    new:ok"
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    ls.Caption = ls.Caption + 1
                    End If
            Case "msg"
                Dim msg_count As Integer
                Dim msg_text As String
                Dim msg_id As String
                Dim msg_data As Variant
                Dim msg_eidok As Boolean
                Dim msg_eidnt As Boolean
                Dim msg_sendid
                
                msg_eidok = True
                msg_eidnt = True
                
                msg_text = Mid(datas, 5, Len(datas) - 4)
                
                For i = 1 To p_cnt
                    If p_user(i, 4) = Index Then
                        msg_sendid = p_user(i, 1)
                    End If
                Next
                
                msg_count = 1
                For i = 1 To Len(msg_text)
                    If msg_count <> 2 Then
                        If Mid(msg_text, i, 1) = ":" Then
                            msg_count = msg_count + 1
                        End If
                        
                        Select Case msg_count
                            Case 1
                                msg_id = msg_id & Mid(msg_text, i, 1)
                                
                            Case 2
                                msg_data = msg_data & Mid(msg_text, i, 1)
                                
                        End Select
                    Else
                        msg_data = msg_data & Mid(msg_text, i, 1)
                    End If
                Next
                
                For i = 1 To p_cnt
                    If p_user(i, 1) = msg_id Then
                        msg_eidok = False
                        
                        For j = 0 To onlist.ListCount - 1
                            If onlist.List(j) = msg_id Then
                                msg_eidnt = False
                            End If
                        Next
                    End If
                Next
                msg_data = Mid(msg_data, 2, Len(msg_data) - 1)
                
                ' 에러처리루틴 (로그온사용자, 비등록사용자 구분 에러처리)
                
                If msg_eidok = True Then
                    msg_eidnt = False
                End If
                
                If msg_eidnt = True Then
                    loglist.AddItem "MSG 로그온사용자가 아님 (쪽지전송실패)" & msg_id & "   Send From (" & msg_sendid & ")"
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    If tcp(Index).State = 7 Then
                    tcp(Index).SendData "msg:eo"
                    DoEvents
                    End If
                    loglist.AddItem "SKID (" & Index & ")   ->    msg:eo"
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    ls.Caption = ls.Caption + 1
                
                ElseIf msg_eidok = True Then
                    loglist.AddItem "MSG 등록사용자가 아님 (쪽지전송실패)" & msg_id & "   Send From (" & msg_sendid & ")"
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    If tcp(Index).State = 7 Then
                    tcp(Index).SendData "msg:en"
                    DoEvents
                    End If
                    loglist.AddItem "SKID (" & Index & ")   ->    msg:en"
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    ls.Caption = ls.Caption + 1
                
                Else
                    For i = 1 To p_cnt
                        If p_user(i, 1) = msg_id Then
                            If tcp(p_user(i, 4)).State = 7 Then
                            tcp(p_user(i, 4)).SendData "msg:ok:" & msg_sendid & ":" & msg_data
                            DoEvents
                            loglist.AddItem "Send Command ->  " & "msg:ok:" & msg_sendid & ":" & msg_data
                            loglist.Selected(loglist.ListCount - 1) = True
                            loglist.Selected(loglist.ListCount - 1) = False
                            ls.Caption = ls.Caption + 1
                            End If
                        End If
                    Next
                End If
                
            Case "fdi"
                Dim fdi_id As String
                Dim fdi_senddata As String
                Dim fdi_result As Boolean
                fdi_result = False
                fdi_id = Mid(datas, 5, Len(datas) - 4)
                
                For i = 1 To p_cnt
                    If fdi_id = p_user(i, 1) Then
                        If tcp(Index).State = 7 Then
                        fdi_senddata = "fdf:01:" & p_user(i, 1) & ":" & p_user(i, 3) & ":" & p_user(i, 13) & ":" & p_user(i, 9) & ":" & p_user(i, 12) & ":"
                        tcp(Index).SendData fdi_senddata
                        DoEvents
                        loglist.AddItem "Send Command ->  To " & Index & " -> " & fdi_senddata
                        loglist.Selected(loglist.ListCount - 1) = True
                        loglist.Selected(loglist.ListCount - 1) = False
                        ls.Caption = ls.Caption + 1
                        fdi_result = True
                        End If
                    End If
                Next
                
                If fdi_result = False Then
                    If tcp(Index).State = 7 Then
                    fdi_senddata = "fdf:00"
                    DoEvents
                    tcp(Index).SendData fdi_senddata
                    loglist.AddItem "Send Command ->  To " & Index & " -> " & fdi_senddata
                    loglist.Selected(loglist.ListCount - 1) = True
                    loglist.Selected(loglist.ListCount - 1) = False
                    ls.Caption = ls.Caption + 1
                    End If
                End If
                
            Case "fdn"
                Dim fdn_name As String
                Dim fdn_senddata As String
                Dim fdn_a As String
                Dim fdn_c As Integer
                Dim fdn_result As Boolean
                fdn_result = False
                fdn_name = Mid(datas, 5, Len(datas) - 4)
                fdn_c = 0
                For i = 1 To p_cnt
                    If fdn_name = p_user(i, 3) Then
                        fdn_a = fdn_a & p_user(i, 1) & ":" & p_user(i, 3) & ":" & p_user(i, 13) & ":" & p_user(i, 9) & ":" & p_user(i, 12) & ":"
                        fdn_c = fdn_c + 1
                        fdn_result = True
                    End If
                Next
                
                If fdn_c < 10 Then
                    fdn_senddata = "fdf:0" & fdn_c & ":" & fdn_a
                Else
                    fdn_senddata = "fdf:" & fdn_c & ":" & fdn_a
                End If
                
                If fdn_result = False Then   '사람이 없을떄 처리
                    If tcp(Index).State = 7 Then
                    fdi_senddata = "fdf:00"
                    tcp(Index).SendData fdn_senddata

======== 중략 ===========

저게 메신저 서버 프로그램의 극 일부라죠;

나름대로 로그인, 쪽지전송등 중요역할을 맡고있는 부분이지만...ㅡㅡ;; 전혀 비효율적인 코딩으로 망해버렸다는...;;

핫핫! 다시 만들고있습니다만..ㅡㅡ 언제 완성될까나;;

id: 점비

2003.09.26 23:51:19
*.240.148.134

흠... 베이직이네... 요즘 소스 올리는게 유행인가-ㅁ-...

id: dri-naru-

2003.09.27 17:33:21
*.154.250.230

아악 머리 빠개져!

id: Sniperking

2003.09.27 23:43:28
*.48.189.139

뿌리부터몰라
List of Articles
번호 제목 글쓴이 날짜sort 조회 수
4164 점비군!! [2] id: Sniperking 2003-10-02 2737
4163 아냥군 -_- [3] id: 점비 2003-10-01 2745
4162 아냥군 -_- [2] id: 시노부 2003-10-01 2667
4161 코룸온라인 해보고서... [1] 뉴트리노 2003-10-01 3493
4160 후후 글수가 매우 줄었군 [1] id: bebop 2003-10-01 2678
4159 FTP 업로드서버개설 / 주소변경 [5] id: 아냥돼지 2003-10-01 2727
4158 아주 삽질해버렸습니다. [3] id: 하루카가 짱이야 2003-09-29 2729
4157 시간때우기용 미니게임(?) 하나..-_-/ [2] 뉴트리노 2003-09-29 3036
4156 대학질문하나..-ㅁ- [8] id: 점비 2003-09-29 2791
4155 오...위험한 세상이야 [2] 동대수석합격생 2003-09-29 2734
4154 누가!! [2] id: Sniperking 2003-09-28 2671
4153 낼부터...다시!! [1] id: Sniperking 2003-09-28 2761
4152 저주받은....언어영역..ㅡㅡ; [3] 똥글^^ 2003-09-28 2683
4151 상륙작전;;; [1] 히비키★ 2003-09-28 2732
4150 음...... [2] id: AciD 2003-09-28 2824
4149 아,아 그렇구나~ [1] 동대수석합격생 2003-09-28 2677
4148 내눈을 똑바로 봐라. [2] id: 하루카가 짱이야 2003-09-28 2681
4147 드디어 휠이 온다 -_-; [1] id: bebop 2003-09-27 2688
4146 인연이란 정말 있는건가..-_-; [6] 뉴트리노 2003-09-27 2723
4145 성적이 전부다~~~~(퍼옴...) SMkeitaro 2003-09-27 2629
4144 그렇담 나도 동참;ㅋ [2] id: 타마~♡ 2003-09-27 2652
4143 에엣! 그럼 나도..-ㅁ-.. [1] id: 점비 2003-09-27 2746
4142 신검결과! 두두둥! [5] id: 하루카가 짱이야 2003-09-26 2734
» 예전에 만들었던 메신저 서브루틴;; [3] id: 아냥돼지 2003-09-26 2725
4140 오늘의 C언어... [3] id: Sniperking 2003-09-26 2850
4139 오랫만에 글쓰네요.. [2] id: 타마~♡ 2003-09-26 2691
4138 요즘 바쁘군요. [1] id: 하루카가 짱이야 2003-09-26 2723
4137 크아... 날 불태울려고 하는가!!!! [3] id: 점비 2003-09-25 2743
4136 요즘 이런걸 만들고 있다. [1] id: 태공망 2003-09-25 2833
4135 음헤헤 [3] id: 최상봉 2003-09-24 2803

Account


New Photo...

이로서 MCP 보유자격 7개... 윈도우7계열 도전중...
id: 냥군 조회 수 12051
ㅋㅋㅋㅋㅋ -웃대 펌
동대수석합격생 조회 수 13518
ㅋㅋㅋ 웃대 펌
동대수석합격생 조회 수 17493
웃대 펌
동대수석합격생 조회 수 20291
웃대 펌...
동대수석합격생 조회 수 40539

Counter



Counter

Total : 3,060,311
Today : 2,257
Yesterday : 2,380

Page View

Total : 81,359,351
Today : 104,913
Yesterday : 114,122

Valid XHTML 1.0 Transitional

Valid CSS Transitional