자유게시판입니다.

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] 박떡 2004-03-12 3032
4643 이젠 아주 막나가는 국회의원 [3] id: 하루카가 짱이야 2004-03-12 2975
4642 탄핵 가결이라.. [3] id: 점비 2004-03-12 3708
4641 아하하~ 14일날 한국가요~ [10] id: 아냥돼지 2004-03-10 3278
4640 리니지중 ㅡㅡa [1] id: 최상봉 2004-03-10 2881
4639 여기저기서 압박...... [2] 박떡 2004-03-09 2950
4638 아- 그냥 -_- 내일이 수능날이었으면.. [3] id: bebop 2004-03-08 2978
4637 버스를 타다가.......ㅡㅡ; 똥글^^ 2004-03-08 2894
4636 왜 날..... id: 하루카가 짱이야 2004-03-08 2883
4635 아냥...큰일났소..-ㅁ-.. id: 점비 2004-03-08 2899
4634 절정의 부진ㅡㅡ;; [1] id: 최상봉 2004-03-08 2913
4633 한국입니다 [4] id: 최상봉 2004-03-05 2986
4632 때아닌 눈에... [1] id: Sniperking 2004-03-05 2944
4631 함박눈과 함께 찾아온 입영통지서 [2] id: 하루카가 짱이야 2004-03-04 2959
4630 으하하하... 동대수석합격생 2004-03-04 2933
4629 오랜만입니다...-_-; [1] 똥글^^ 2004-03-04 2979
4628 아냥군...한국올&#46468;되지않았소? id: Sniperking 2004-03-04 5655
4627 또 써서 죄송하군요 ㅡㅡ;; [1] id: 최상봉 2004-03-03 3035
4626 고3 생활의 압박...... [4] 박떡 2004-03-03 2932
4625 대충.. [5] id: 시노부 2004-03-02 2962
4624 유후~ [1] 동대수석합격생 2004-03-02 2894
4623 즐~ 같은 수강신청-_-; [2] 점비 2004-03-02 3032
4622 슬슬 준비를 해야겠군 id: 최상봉 2004-03-02 2845
4621 개학이닷!! [1] id: Sniperking 2004-03-02 3012
4620 내일이 개학인 게죠... [2] 박떡 2004-03-01 3031
4619 3월 5일 간다~ [2] id: 최상봉 2004-03-01 2851
4618 둠3? [3] id: bebop 2004-03-01 2902
4617 3.1 절이네요~ [2] HolyBell 2004-03-01 2975
4616 도착이여...케케 [3] 동대수석합격생 2004-02-29 2866
4615 점비군..쇼파건..=ㅁ= 마지막 [1] id: 아냥돼지 2004-02-29 3913

Account


New Photo...

이로서 MCP 보유자격 7개... 윈도우7계열 도전중...
id: 냥군 조회 수 12151
ㅋㅋㅋㅋㅋ -웃대 펌
동대수석합격생 조회 수 13701
ㅋㅋㅋ 웃대 펌
동대수석합격생 조회 수 17637
웃대 펌
동대수석합격생 조회 수 20504
웃대 펌...
동대수석합격생 조회 수 40674

Counter



Counter

Total : 3,100,661
Today : 2,184
Yesterday : 2,342

Page View

Total : 85,840,809
Today : 440,661
Yesterday : 582,772

Valid XHTML 1.0 Transitional

Valid CSS Transitional