Java开发的GeekBrains即时通讯系统介绍

需积分: 9 0 下载量 56 浏览量 更新于2024-12-22 收藏 7KB ZIP 举报
资源摘要信息: "GeekBrains lvl-2 FX Chat" 本资源集重点围绕Java编程语言进行开发,特别是在实现聊天应用方面。在当今的软件开发领域中,创建即时通信系统是一个普遍的需求,这类系统通常包括客户端、服务器端以及两者之间的网络通信。Java作为一门广泛使用的编程语言,因其跨平台特性、良好的网络支持和成熟的生态系统,在构建此类系统时尤其受到开发者的青睐。 知识点概述: 1. Java编程基础: Java语言具备面向对象的特性,允许开发者创建易于管理和复用的代码。资源集强调Java的基础知识,包括类、对象、继承、多态以及接口等概念,这些都是构建复杂应用程序所必须的。 2. Java网络编程: 在聊天应用中,网络编程是核心部分,涉及到客户端和服务器之间的数据交换。Java提供了丰富的网络API,包括套接字编程(Socket Programming),可以用来实现服务器端和客户端的连接、数据传输和接收。 3. Java图形用户界面(GUI): FX Chat项目中的"FX"很可能指的是JavaFX,它是Java的一个官方图形用户界面库,用于创建富客户端应用程序。通过JavaFX,开发者可以构建交互式、具有吸引力的用户界面,并与后端逻辑进行集成。 4. 多线程编程: 在实现聊天应用时,多线程是一个重要概念。服务器端需要能够同时处理来自多个客户端的连接和消息,这就需要使用Java的线程管理功能。了解如何创建、同步和管理线程对于构建可扩展的聊天系统至关重要。 5. 异步编程模式: 聊天系统中,消息的接收和发送往往采用异步方式,以避免阻塞用户界面或服务器资源。Java提供了Future、Callable和CompletableFuture等异步编程模型,用以支持非阻塞的调用和结果处理。 6. 实现聊天协议: 聊天应用需要一个特定的协议来定义客户端和服务器间交换消息的格式和规则。这涉及到协议设计、编码和解码消息以及实现消息的分发逻辑。 7. 安全性和加密: 网络通信中的数据安全性是不可忽视的部分。在资源集中,可能也会涉及到安全传输数据,如使用SSL/TLS协议加密数据流,或者实现消息的加密和解密,保证消息内容不被未授权用户访问。 8. 调试和测试: 聊天系统开发过程中,需要对系统进行彻底的测试,包括单元测试、集成测试以及压力测试。资源集可能包含关于如何使用Java测试框架如JUnit进行测试的知识点。 9. 版本控制和项目管理: 任何项目都需要版本控制系统来追踪代码变更,管理项目的构建过程,以及协作开发。资源集中可能会包含使用Git等版本控制工具的知识,以及利用Maven或Gradle进行项目构建和依赖管理的内容。 根据以上知识点,GeekBrains lvl-2 FX Chat资源集可能是针对有一定Java基础的开发者,旨在通过实战项目提升其在网络编程、GUI设计、多线程处理以及系统安全等方面的能力。通过动手实践,开发者可以更深入地理解和掌握如何构建一个完整的即时通讯系统。

#include <rtthread.h> #include <rtdevice.h> #include "ft6236.h" #include "touch.h" #include "drv_common.h" #include <rttlogo.h> #include "drv_spi_ili9488.h" #define DBG_TAG "ft6236_example" #define DBG_LVL DBG_LOG #include <rtdbg.h> rt_thread_t ft6236_thread; rt_device_t touch; void ft6236_thread_entry(void *parameter) { struct rt_touch_data *read_data; rt_uint16_t touch_x,touch_y; rt_uint8_t i; read_data = (struct rt_touch_data *)rt_calloc(1, sizeof(struct rt_touch_data)); while(1) { rt_device_read(touch, 0, read_data, 1); if (read_data->event == RT_TOUCH_EVENT_DOWN) { rt_kprintf("down x: %03d y: %03d", read_data->x_coordinate, read_data->y_coordinate); rt_kprintf(" t: %d\n", read_data->timestamp); for(i=0;i<13;i++)//计算落子的x坐标 { if(abs((read_data->y_coordinate)-(16+24*i))<12) { touch_x=16+24*i; break; } } for(i=0;i<13;i++)//计算落子的y坐标 { if(abs((320-(read_data->x_coordinate))-(16+24*i))<12) { touch_y=16+24*i; break; } } //落子 lcd_show_image(touch_x-12, touch_y-12, 24, 24, acwhite); } if (read_data->event == RT_TOUCH_EVENT_MOVE) { rt_kprintf("move x: %03d y: %03d", read_data->x_coordinate, read_data->y_coordinate); rt_kprintf(" t: %d\n", read_data->timestamp); } if (read_data->event == RT_TOUCH_EVENT_UP) { rt_kprintf("up x: %03d y: %03d", read_data->x_coordinate, read_data->y_coordinate); rt_kprintf(" t: %d\n\n", read_data->timestamp); } rt_thread_delay(10); } } #define REST_PIN GET_PIN(D, 3) int ft6236_example(void) { struct rt_touch_config cfg; cfg.dev_name = "i2c2"; rt_hw_ft6236_init("touch", &cfg, REST_PIN); touch = rt_device_find("touch"); rt_device_open(touch, RT_DEVICE_FLAG_RDONLY); struct rt_touch_info info; rt_device_control(touch, RT_TOUCH_CTRL_GET_INFO, &info); LOG_I("type :%d", info.type); LOG_I("vendor :%d", info.vendor); LOG_I("point_num :%d", info.point_num); LOG_I("range_x :%d", info.range_x); LOG_I("range_y :%d", info.range_y); ft6236_thread = rt_thread_create("touch", ft6236_thread_entry, RT_NULL, 800, 10, 20); if (ft6236_thread == RT_NULL) { LOG_D("create ft6236 thread err"); return -RT_ENOMEM; } rt_thread_startup(ft6236_thread); return RT_EOK; } INIT_APP_EXPORT(ft6236_example);

2023-06-01 上传

static void battery_module_capture_process(battery_capture_type_t capture_type) { device_batt_info_t *p_batt = (device_batt_info_t *)store_driver_get(STORE_DATA_ID_BATT_INFO); device_mode_factory_t *p_mode = (device_mode_factory_t *)store_driver_get(STORE_DATA_ID_MODE_STATUS); if(capture_type == BATTERY_CAPTURE_TYPE_UP) { //启动充电动画 ui_module_set_menu_class(UI_MODULE_MENU_BAT); g_battery_module_mgr.b_low_voltage = false; g_battery_module_mgr.capacity.init_time_count = my_fw_timer_hw_get_cnt(); g_battery_module_mgr.capacity.before_charge_persentage = p_batt->battery_persentage; battery_module_tick_check_process(); if(p_mode->f1 == SYSTEM_MODE_WORK) { } else { my_fw_sched_event_put(FACTORY_MODULE_EVENT_CHARGE_DEFAULT,0,NULL,MID_LVL_EVT); } } else { //去除充电动画 ui_module_set_menu_class(UI_MODULE_MENU_NONE); g_battery_module_mgr.capacity.b_discharge_delay = true; g_battery_module_mgr.factory_data.init_discharge_count = my_fw_timer_hw_get_cnt(); g_battery_module_mgr.capacity.charge_time = 0; g_battery_module_mgr.factory_data.discharge_time = 0; g_battery_module_mgr.factory_data.b_discharge_init_per= false; g_battery_module_mgr.capacity.after_charge_persentage = p_batt->battery_persentage; my_fw_tm_start(REMOTE_MODULE_EVENT_TIMEOUT,0,NULL,ROWER_TIMEOUT); //my_fw_sched_event_put(UI_MODULE_EVENT_MENU_DISCHARGE_DEFAULT,0,NULL,MID_LVL_EVT); if(p_mode->f1 == SYSTEM_MODE_WORK) { my_fw_sched_event_put(UI_MODULE_EVENT_MENU_DISCHARGE_DEFAULT,0,NULL,MID_LVL_EVT); } else { my_fw_sched_event_put(FACTORY_MODULE_EVENT_DISCHARGE_DEFAULT,0,NULL,MID_LVL_EVT); } } }

2023-06-06 上传

int dsi_panel_set_backlight(struct dsi_panel panel, u32 bl_lvl) { int rc = 0; struct dsi_backlight_config bl = &panel->bl_config; if (panel->host_config.ext_bridge_mode) return 0; DSI_DEBUG("backlight type:%d lvl:%d\n", bl->type, bl_lvl); switch (bl->type) { case DSI_BACKLIGHT_WLED: rc = backlight_device_set_brightness(bl->raw_bd, bl_lvl); break; case DSI_BACKLIGHT_DCS: rc = dsi_panel_update_backlight(panel, bl_lvl); break; case DSI_BACKLIGHT_EXTERNAL: rc = lcd_bl_set_led_brightness(bl_lvl); //pr_err("dsi set bias brightness: %d\n", bl_lvl); rc = lcd_bias_set_led_brightness(bl_lvl); //pr_err("dsi set brightness: %d\n", bl_lvl); break; case DSI_BACKLIGHT_PWM: rc = dsi_panel_update_pwm_backlight(panel, bl_lvl); break; default: DSI_ERR("Backlight type(%d) not supported\n", bl->type); rc = -ENOTSUPP; } return rc; } int lcd_bl_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_i2c_client->dev, "value=%d\n", value); return 0; } if (value > 0) { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); / BL enabled and Current sink 1/2/3/4 enabled;/ } else { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); /* BL enabled and Current sink 1/2/3/4 disabled;/ } return 0; } int lcd_bias_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_bias_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_bias_i2c_client->dev, "invalid value=%d\n", value); return 0; } if (value > 0) { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); / BL enabled and Current sink 1/2/3/4 enabled;/ } else { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); / BL enabled and Current sink 1/2/3/4 disabled;*/ } return 0; } dsi_panel_set_backlight、lcd_bl_set_led_brightness和lcd_bias_set_led_brightness源码如上,帮忙用内核线程的方式,同时实现在case DSI_BACKLIGHT_EXTERNAL:下并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数

2023-06-07 上传

int dsi_panel_set_backlight(struct dsi_panel *panel, u32 bl_lvl) { int rc = 0; struct dsi_backlight_config *bl = &panel->bl_config; if (panel->host_config.ext_bridge_mode) return 0; DSI_DEBUG("backlight type:%d lvl:%d\n", bl->type, bl_lvl); switch (bl->type) { case DSI_BACKLIGHT_WLED: rc = backlight_device_set_brightness(bl->raw_bd, bl_lvl); break; case DSI_BACKLIGHT_DCS: rc = dsi_panel_update_backlight(panel, bl_lvl); break; case DSI_BACKLIGHT_EXTERNAL: rc = lcd_bl_set_led_brightness(bl_lvl); //pr_err("dsi set bias brightness: %d\n", bl_lvl); rc = lcd_bias_set_led_brightness(bl_lvl); //pr_err("dsi set brightness: %d\n", bl_lvl); break; case DSI_BACKLIGHT_PWM: rc = dsi_panel_update_pwm_backlight(panel, bl_lvl); break; default: DSI_ERR("Backlight type(%d) not supported\n", bl->type); rc = -ENOTSUPP; } return rc; } int lcd_bl_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_i2c_client->dev, "value=%d\n", value); return 0; } if (value > 0) { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); /* BL enabled and Current sink 1/2/3/4 enabled;*/ } else { lcd_bl_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); /* BL enabled and Current sink 1/2/3/4 disabled;*/ } return 0; } int lcd_bias_set_led_brightness(int value)//for set bringhtness { dev_warn(&lcd_bl_bias_i2c_client->dev, "lcm 8866 bl = %d\n", value); if (value < 0) { dev_warn(&lcd_bl_bias_i2c_client->dev, "invalid value=%d\n", value); return 0; } if (value > 0) { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, value & 0x07);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, (value >> 3) & 0xFF);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x4F); /* BL enabled and Current sink 1/2/3/4 enabled;*/ } else { lcd_bl_bias_write_byte(KTZ8866_DISP_BB_LSB, 0x00);// lsb lcd_bl_bias_write_byte(KTZ8866_DISP_BB_MSB, 0x00);// msb lcd_bl_bias_write_byte(KTZ8866_DISP_BL_ENABLE, 0x00); /* BL enabled and Current sink 1/2/3/4 disabled;*/ } return 0; } dsi_panel_set_backlight、lcd_bl_set_led_brightness和lcd_bias_set_led_brightness源码如上,帮忙用内核线程的方式,同时实现在case DSI_BACKLIGHT_EXTERNAL:下并发执行lcd_bl_set_led_brightness和lcd_bias_set_led_brightness两个函数

2023-06-07 上传