자유게시판입니다.

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 조회 수
4644 모의고사 끝나고 얻은것 두가지. [3] id: Cooni 2003-03-28 3032
4643 아..그럼 열분 [2] id: Sniperking 2003-03-29 3043
4642 아......심심해... [1] id: 최상봉 2003-03-29 2960
4641 아아.. 모의고사.. [6] 운명론자 2003-03-29 3082
4640 음- 모임 못갈듯 [3] id: bebop 2003-03-29 3339
4639 아흥,...ㅠㅠ 이제 하루 남았네요.. [3] id: 아냥돼지 2003-03-29 3054
4638 예고대로.....나도 적는다!!!! 휴잉..;; [2] 똥글^^ 2003-03-29 3051
4637 수능가. [7] id: Cooni 2003-03-29 2962
4636 으아아아악!!다음부터는... [3] id: Sniperking 2003-03-30 2967
4635 드림위즈도 날 엿먹이는건가..... [2] id: 하루카가 짱이야 2003-03-30 3045
4634 우리반 친구하나가 한국으로 컴백했습니다 [1] id: 최상봉 2003-03-30 3517
4633 -_-/ 같이 섀도우베인하자. [4] 나는너 2003-03-30 3077
4632 이번 모의고사.. [4] 운명론자 2003-03-30 3030
4631 &#48577;&#48577;&#48577;... [5] id: 태공망 2003-03-30 3033
4630 아냥님...^_^;; [5] 똥글^^ 2003-03-30 3108
4629 음음---------- [5] id: bebop 2003-03-30 3069
4628 흐... 이거 문제가 있을것 같은 생각이 드는군요.. [5] SMkeitaro 2003-03-30 2952
4627 음하하핫!! [3] id: Sniperking 2003-03-30 2941
4626 가끔 생각하는건데 ㅡㅡ;; [6] SMkeitaro 2003-03-31 3046
4625 아&#54671;&#54671;..... [2] id: Sniperking 2003-03-31 3085
4624 계정에대해 물어볼것이 있는데........... [3] id: 하루카가 짱이야 2003-03-31 3032
4623 시간이 어중간하게 남는것도 완전 고문이군요 [1] id: 최상봉 2003-03-31 2995
4622 핵교! [4] 운명론자 2003-03-31 3105
4621 우라질 테스트 [5] id: 하루카가 짱이야 2003-03-31 3030
4620 아버지가.. [10] id: 태공망 2003-04-01 3078
4619 으흑 감동했습니다 T^TQ [2] SMkeitaro 2003-04-01 3031
4618 일본학교 휴교다!! [2] id: 최상봉 2003-04-01 2942
4617 컴퓨터 정리하다 나온것 - (1) [5] id: 하루카가 짱이야 2003-04-01 3091
4616 1년전부터 제게 걸려있던 것 [4] id: 하루카가 짱이야 2003-04-01 3065
4615 참 이상한거....... [1] id: 하루카가 짱이야 2003-04-01 3033

Account


New Photo...

이로서 MCP 보유자격 7개... 윈도우7계열 도전중...
id: 냥군 조회 수 12159
ㅋㅋㅋㅋㅋ -웃대 펌
동대수석합격생 조회 수 13709
ㅋㅋㅋ 웃대 펌
동대수석합격생 조회 수 17642
웃대 펌
동대수석합격생 조회 수 20530
웃대 펌...
동대수석합격생 조회 수 40684

Counter



Counter

Total : 3,107,930
Today : 1,790
Yesterday : 2,695

Page View

Total : 87,474,934
Today : 322,969
Yesterday : 595,353

Valid XHTML 1.0 Transitional

Valid CSS Transitional