자유게시판입니다.

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
2334 이번달 지름신현황(?)..-_-;; [3] 사하린 2006-09-24 2791
2333 공감자료- [3] id: Cooni 2006-08-18 2791
2332 시험시험시험시험... 동대수석합격생 2006-04-18 2791
2331 아..-_-;; [3] 사하린 2006-03-19 2791
2330 아냥님!!! 제발전화좀 받으세요 -ㅁ-!! [1] 사하린 2006-01-20 2791
2329 크리스마스로군요. [1] 동대수석합격생 2005-12-25 2791
2328 방학했습니다, [5] id: Cooni 2005-12-04 2791
2327 오랜만에 첫글먹어보자 [1] id: Sniperking 2005-11-28 2791
2326 아~ 성계의 전기3 1편 동생이 다운받고있데요 [2] id: Sniperking 2005-08-08 2791
2325 어찢티니리 [3] sahalin 2005-07-12 2791
2324 결국... [1] 사하린 2005-07-08 2791
2323 세상에는 여러 오타쿠가 존재합니다만-_- [7] id: 아냥돼지 2005-06-03 2791
2322 나에게 첫글을 넘겨주는건. [1] id: Cooni 2005-04-23 2791
2321 .. 잔액이 부족.. [2] 냥군 2005-04-01 2791
2320 ..첫글.. [2] 태공망 2005-03-08 2791
2319 [1] id: Sniperking 2005-01-14 2791
2318 첫글 [2] id: Sniperking 2004-12-23 2791
2317 2연속 승리... [3] 점비 2004-12-19 2791
2316 아.. 오랫만에 질문 한가지.. [9] id: 아냥돼지 2004-11-29 2791
2315 아냥 한국에 왔다면... id: 점비 2004-03-15 2791
2314 이미 끝났지만....-_-b;;; [4] id: 점비 2004-01-03 2791
2313 새해 복 많이 받으세요!!-하지만 베트남은 아직 새해가 아니군요 ㅡㅡ;; [1] id: 최상봉 2004-01-01 2791
2312 모두 새해복 많이 받으십시요! [4] 이미조용해 2003-12-31 2791
2311 아윽... 일어판 윈도우를 빨리 받아야 되는데;; [2] id: 아냥돼지 2003-10-06 2791
» 예전에 만들었던 메신저 서브루틴;; [3] id: 아냥돼지 2003-09-26 2790
2309 내가 지금 개학함을 실감했다... [1] id: Sniperking 2003-09-01 2791
2308 아아아악 대체 언제 나오냐 ! ;ㅁ; [6] 나는너 2003-08-24 2791
2307 아아...드디어 올것이 왔구나... [5] id: Sniperking 2003-08-22 2791
2306 여!!3년인가... [3] 히비키★ 2003-08-14 2791
2305 더 야마노테센... [5] id: 아냥돼지 2003-08-12 2791

Account


New Photo...

이로서 MCP 보유자격 7개... 윈도우7계열 도전중...
id: 냥군 조회 수 12129
ㅋㅋㅋㅋㅋ -웃대 펌
동대수석합격생 조회 수 13666
ㅋㅋㅋ 웃대 펌
동대수석합격생 조회 수 17615
웃대 펌
동대수석합격생 조회 수 20457
웃대 펌...
동대수석합격생 조회 수 40645

Counter



Counter

Total : 3,085,040
Today : 2,155
Yesterday : 2,871

Page View

Total : 83,210,910
Today : 224,094
Yesterday : 264,832

Valid XHTML 1.0 Transitional

Valid CSS Transitional